Skip to content

Commit 64070c8

Browse files
committed
Product's price is not correct inside wishlist reimplementation
1 parent 5d8a3ac commit 64070c8

File tree

8 files changed

+27
-209
lines changed

8 files changed

+27
-209
lines changed

app/code/Magento/ConfigurableProduct/Helper/Catalog/Product/Configuration.php

Lines changed: 0 additions & 151 deletions
This file was deleted.

app/code/Magento/ConfigurableProduct/Helper/Product/Configuration/Plugin.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
*/
77
namespace Magento\ConfigurableProduct\Helper\Product\Configuration;
88

9-
/**
10-
* @deprecated
11-
* @see Magento\ConfigurableProduct\Helper\Catalog\Product\Configuration
12-
*/
139
class Plugin
1410
{
1511
/**

app/code/Magento/ConfigurableProduct/Observer/InitOptionRendererObserver.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/code/Magento/ConfigurableProduct/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Model\Order\Admin\Item\Plugin\Configurable" sortOrder="50" />
3131
</type>
3232
<type name="Magento\Catalog\Helper\Product\Configuration">
33-
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Helper\Product\Configuration\Plugin" sortOrder="50" disabled="true"/>
33+
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Helper\Product\Configuration\Plugin" sortOrder="50" />
3434
</type>
3535
<type name="Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend">
3636
<plugin name="ConfigurableProduct::skipValidation" type="Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation"/>

app/code/Magento/ConfigurableProduct/etc/frontend/di.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
10-
<type name="Magento\Catalog\Helper\Product\ConfigurationPool">
11-
<arguments>
12-
<argument name="instancesByType" xsi:type="array">
13-
<item name="configurable" xsi:type="object">Magento\ConfigurableProduct\Helper\Catalog\Product\Configuration</item>
14-
</argument>
15-
</arguments>
16-
</type>
1710
<type name="Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface">
1811
<plugin name="Magento_ConfigurableProduct_Plugin_Model_ResourceModel_Attribute_InStockOptionSelectBuilder" type="Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder"/>
1912
<plugin name="option_select_website_filter" type="Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\ScopedOptionSelectBuilder"/>

app/code/Magento/ConfigurableProduct/etc/frontend/events.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Options.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ public function getConfiguredOptions()
118118
}
119119
}
120120
$options[$index]['value'] = $option['value'];
121-
if (array_key_exists('price', $option)) {
122-
$options[$index]['value'] = $option['value'] .' '. $option['price'];
123-
}
124121
}
125122
}
126123

app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ConfigurableProduct extends AbstractPrice
1717
/**
1818
* Price type final.
1919
*/
20-
const PRICE_CODE = 'final_price';
20+
public const PRICE_CODE = 'final_price';
2121

2222
/**
2323
* @var ItemInterface
@@ -57,8 +57,31 @@ public function getConfiguredRegularAmount(): \Magento\Framework\Pricing\Amount\
5757
*/
5858
public function getValue()
5959
{
60+
/** @var \Magento\Catalog\Model\Product $configurableProduct */
61+
$configurableProduct = parent::getProduct();
62+
63+
/** @var \Magento\Wishlist\Model\Item\Option $configurableCustomOption */
64+
$configurableCustomOption = $configurableProduct->getCustomOption('option_ids');
65+
$customPrice = 0;
66+
if ($configurableCustomOption) {
67+
$item = $this->item;
68+
foreach (explode(',', $configurableCustomOption->getValue()) as $optionId) {
69+
$option = $configurableProduct->getOptionById($optionId);
70+
if ($option) {
71+
$itemOption = $item->getOptionByCode('option_' . $option->getId());
72+
/** @var $group \Magento\Catalog\Model\Product\Option\Type\DefaultType */
73+
$group = $option->groupFactory($option->getType())
74+
->setOption($option)
75+
->setConfigurationItemOption($itemOption);
76+
$basePrice = $configurableProduct->getPriceInfo()->getPrice('final_price')->getAmount()->getValue();
77+
$customPrice += $group->getOptionPrice($itemOption->getValue(), $basePrice);
78+
}
79+
}
80+
}
6081
$price = $this->getProduct()->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue();
61-
82+
if ($customPrice) {
83+
$price = $price + $customPrice;
84+
}
6285
return max(0, $price);
6386
}
6487

@@ -78,6 +101,7 @@ public function getProduct()
78101
{
79102
/** @var \Magento\Catalog\Model\Product $product */
80103
$product = parent::getProduct();
104+
81105
/** @var \Magento\Wishlist\Model\Item\Option $customOption */
82106
$customOption = $product->getCustomOption('simple_product');
83107

0 commit comments

Comments
 (0)