Skip to content

Commit 2e2785c

Browse files
committed
Merge pull request #683 from magento-firedrakes/MAGETWO-41948
[Firedrakes][South][Tango][FearlessKiwis] MAGETWO-41984 MAGETWO-41944 Convert Quoteitem to order item with product options
2 parents 86d5abe + c7f915c commit 2e2785c

File tree

141 files changed

+4919
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+4919
-299
lines changed

app/code/Magento/Backend/App/AbstractAction.php

-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ protected function _processLocaleSettings()
300300
/**
301301
* Set redirect into response
302302
*
303-
* @deprecated
304303
* @TODO MAGETWO-28356: Refactor controller actions to new ResultInterface
305304
* @param string $path
306305
* @param array $arguments
@@ -316,7 +315,6 @@ protected function _redirect($path, $arguments = [])
316315
/**
317316
* Forward to action
318317
*
319-
* @deprecated
320318
* @TODO MAGETWO-28356: Refactor controller actions to new ResultInterface
321319
* @param string $action
322320
* @param string|null $controller

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors
1212
* @method boolean getHideFormElement()
1313
* @author Magento Core Team <core@magentocommerce.com>
14-
* @deprecated support Magento 1.x grid massaction implementation
1514
* @TODO MAGETWO-31510: Remove deprecated class
1615
*/
1716
class Extended extends \Magento\Backend\Block\Widget

app/code/Magento/Backend/view/adminhtml/templates/widget/grid/massaction_extended.phtml

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
// @codingStandardsIgnoreFile
88

9-
/**
10-
* @deprecated support Magento 1.x grid massaction implementation
11-
*/
129
?>
1310
<div id="<?php echo $block->getHtmlId() ?>" class="admin__grid-massaction">
1411

app/code/Magento/Bundle/Model/CartItemProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function convertToBuyRequest(CartItemInterface $cartItem)
7676
* {@inheritdoc}
7777
* @SuppressWarnings(PHPMD.NPathComplexity)
7878
*/
79-
public function processProductOptions(CartItemInterface $cartItem)
79+
public function processOptions(CartItemInterface $cartItem)
8080
{
8181
if ($cartItem->getProductType() !== \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
8282
return $cartItem;

app/code/Magento/Bundle/Model/Product/Price.php

-3
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ public function getIsPricesCalculatedByIndex()
9797
*
9898
* @param \Magento\Catalog\Model\Product $product
9999
* @return float
100-
*
101-
* @deprecated (MAGETWO-31476)
102100
*/
103101
public function getPrice($product)
104102
{
@@ -375,7 +373,6 @@ public function getOptions($product)
375373
* @param null|bool $multiplyQty Whether to multiply selection's price by its quantity
376374
* @return float
377375
*
378-
* @deprecated after 1.6.2.0 (MAGETWO-31475)
379376
* @see \Magento\Bundle\Model\Product\Price::getSelectionFinalTotalPrice()
380377
*/
381378
public function getSelectionPrice($bundleProduct, $selectionProduct, $selectionQty = null, $multiplyQty = true)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Bundle\Model;
7+
8+
use Magento\Bundle\Api\Data\BundleOptionInterface;
9+
use Magento\Bundle\Api\Data\BundleOptionInterfaceFactory;
10+
use Magento\Catalog\Api\Data\ProductOptionInterface;
11+
use Magento\Catalog\Model\Product\Type as ProductType;
12+
use Magento\Catalog\Model\ProductOptionProcessorInterface;
13+
use Magento\Framework\DataObject;
14+
use Magento\Framework\DataObject\Factory as DataObjectFactory;
15+
16+
class ProductOptionProcessor implements ProductOptionProcessorInterface
17+
{
18+
/**
19+
* @var DataObjectFactory
20+
*/
21+
protected $objectFactory;
22+
23+
/**
24+
* @var BundleOptionInterfaceFactory
25+
*/
26+
protected $bundleOptionFactory;
27+
28+
/**
29+
* @param DataObjectFactory $objectFactory
30+
* @param BundleOptionInterfaceFactory $bundleOptionFactory
31+
*/
32+
public function __construct(
33+
DataObjectFactory $objectFactory,
34+
BundleOptionInterfaceFactory $bundleOptionFactory
35+
) {
36+
$this->objectFactory = $objectFactory;
37+
$this->bundleOptionFactory = $bundleOptionFactory;
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function convertToBuyRequest(ProductOptionInterface $productOption)
44+
{
45+
/** @var DataObject $request */
46+
$request = $this->objectFactory->create();
47+
48+
$bundleOptions = $this->getBundleOptions($productOption);
49+
if (!empty($bundleOptions) && is_array($bundleOptions)) {
50+
$requestData = [];
51+
foreach ($bundleOptions as $option) {
52+
/** @var BundleOptionInterface $option */
53+
foreach ($option->getOptionSelections() as $selection) {
54+
$requestData['bundle_option'][$option->getOptionId()][] = $selection;
55+
$requestData['bundle_option_qty'][$option->getOptionId()] = $option->getOptionQty();
56+
}
57+
}
58+
$request->addData($requestData);
59+
}
60+
61+
return $request;
62+
}
63+
64+
/**
65+
* Retrieve bundle options
66+
*
67+
* @param ProductOptionInterface $productOption
68+
* @return array
69+
*/
70+
protected function getBundleOptions(ProductOptionInterface $productOption)
71+
{
72+
if ($productOption
73+
&& $productOption->getExtensionAttributes()
74+
&& $productOption->getExtensionAttributes()->getBundleOptions()
75+
) {
76+
return $productOption->getExtensionAttributes()
77+
->getBundleOptions();
78+
}
79+
return [];
80+
}
81+
82+
/**
83+
* {@inheritdoc}
84+
*/
85+
public function convertToProductOption(DataObject $request)
86+
{
87+
$bundleOptions = $request->getBundleOption();
88+
$bundleOptionsQty = $request->getBundleOptionQty();
89+
90+
if (!empty($bundleOptions) && is_array($bundleOptions)) {
91+
$data = [];
92+
foreach ($bundleOptions as $optionId => $optionSelections) {
93+
if (empty($optionSelections)) {
94+
continue;
95+
}
96+
$optionSelections = is_array($optionSelections) ? $optionSelections : [$optionSelections];
97+
$optionQty = isset($bundleOptionsQty[$optionId]) ? $bundleOptionsQty[$optionId] : 1;
98+
99+
/** @var BundleOptionInterface $productOption */
100+
$productOption = $this->bundleOptionFactory->create();
101+
$productOption->setOptionId($optionId);
102+
$productOption->setOptionSelections($optionSelections);
103+
$productOption->setOptionQty($optionQty);
104+
$data[] = $productOption;
105+
}
106+
107+
return ['bundle_options' => $data];
108+
}
109+
110+
return [];
111+
}
112+
}

app/code/Magento/Bundle/Pricing/Render/FinalPriceBox.php

+16-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,33 @@
88

99
use Magento\Bundle\Pricing\Price;
1010
use Magento\Catalog\Pricing\Render as CatalogRender;
11+
use Magento\Catalog\Pricing\Price\CustomOptionPrice;
1112

1213
/**
1314
* Class for final_price rendering
1415
*/
1516
class FinalPriceBox extends CatalogRender\FinalPriceBox
1617
{
1718
/**
18-
* Check if bundle product has one more custom option with different prices
19+
* Check if bundle product has one or more options, or custom options, with different prices
1920
*
2021
* @return bool
2122
*/
2223
public function showRangePrice()
2324
{
24-
/** @var Price\BundleOptionPrice $optionPrice */
25-
$optionPrice = $this->getPriceType(Price\BundleOptionPrice::PRICE_CODE);
26-
return $optionPrice->getValue() !== $optionPrice->getMaxValue();
25+
//Check the bundle options
26+
/** @var Price\BundleOptionPrice $bundleOptionPrice */
27+
$bundleOptionPrice = $this->getPriceType(Price\BundleOptionPrice::PRICE_CODE);
28+
$showRange = $bundleOptionPrice->getValue() != $bundleOptionPrice->getMaxValue();
29+
30+
if (!$showRange) {
31+
//Check the custom options, if any
32+
/** @var \Magento\Catalog\Pricing\Price\CustomOptionPrice $customOptionPrice */
33+
$customOptionPrice = $this->getPriceType(CustomOptionPrice::PRICE_CODE);
34+
$showRange =
35+
$customOptionPrice->getCustomOptionRange(true) != $customOptionPrice->getCustomOptionRange(false);
36+
}
37+
38+
return $showRange;
2739
}
2840
}

app/code/Magento/Bundle/Test/Unit/Model/CartItemProcessorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ public function testProcessProductOptions()
147147
$cartItemMock->expects($this->atLeastOnce())->method('getProductOption')->willReturn($productOptionMock);
148148
$productOptionMock->expects($this->once())->method('setExtensionAttributes')->with($optionExtensionMock);
149149

150-
$this->assertSame($cartItemMock, $this->model->processProductOptions($cartItemMock));
150+
$this->assertSame($cartItemMock, $this->model->processOptions($cartItemMock));
151151
}
152152

153153
public function testProcessProductOptionsInvalidType()
154154
{
155155
$cartItemMock = $this->getMock('\Magento\Quote\Model\Quote\Item', ['getProductType'], [], '', false);
156156
$cartItemMock->expects($this->once())->method('getProductType')->willReturn(Type::TYPE_SIMPLE);
157-
$this->assertSame($cartItemMock, $this->model->processProductOptions($cartItemMock));
157+
$this->assertSame($cartItemMock, $this->model->processOptions($cartItemMock));
158158
}
159159
}

0 commit comments

Comments
 (0)