55 if ($this->weeeData->isEnabled()) {
56 $priceConfigObj =
$observer->getData(
'configObj');
59 $product = $this->registry->registry(
'current_product');
60 $weeeAttributesForBundle = $this->weeeData->getWeeeAttributesForBundle(
$product);
61 $priceConfig = $this->recurConfigAndInsertWeeePrice(
62 $priceConfigObj->getConfig(),
65 $weeeAttributesForBundle
67 $priceConfigObj->setConfig($priceConfig);
68 }
catch (\Exception $e) {
84 private function recurConfigAndInsertWeeePrice($input, $searchKey, $calcPrice, $weeeAttributesForBundle =
null)
87 if (is_array($input)) {
88 foreach ($input as $key => $el) {
91 $this->recurConfigAndInsertWeeePrice($el, $searchKey, $calcPrice, $weeeAttributesForBundle);
92 if ($key === $searchKey) {
93 if ((!array_key_exists(
'weeePrice', $holder[$key])) &&
94 (array_key_exists($calcPrice, $holder[$key]))
97 $holder[$key][
'weeePrice'] = $holder[$key][$calcPrice];
99 if (array_key_exists(
'optionId', $input) && $weeeAttributesForBundle) {
100 $holder = $this->insertWeeePrice($holder, $key, $weeeAttributesForBundle);
120 private function insertWeeePrice($holder, $key, $weeeAttributesForBundle)
122 if (array_key_exists($holder[
'optionId'], $weeeAttributesForBundle)) {
123 if (count($weeeAttributesForBundle[$holder[
'optionId']]) > 0 &&
124 is_array($weeeAttributesForBundle[$holder[
'optionId']])
127 foreach ($weeeAttributesForBundle[$holder[
'optionId']] as $weeeAttribute) {
128 $holder[$key][
'weeePrice' . $weeeAttribute->getCode()] =
129 [
'amount' => (float)$weeeAttribute->getAmount()];
130 $weeeSum += (float)$weeeAttribute->getAmount();
132 $holder[$key][
'weeePrice'][
'amount'] += (float)$weeeSum;
135 unset($holder[$key][
'weeePrice']);
150 $calcPrice =
'finalPrice';
151 if (!empty($weeeAttributesForBundle)) {
152 if ($this->weeeData->isDisplayExcl(
$storeId) ||
153 $this->weeeData->isDisplayExclDescIncl(
$storeId) ||
154 ($this->taxData->priceIncludesTax() && $this->taxData->displayPriceExcludingTax())
156 $calcPrice =
'basePrice';
__construct(\Magento\Framework\Registry $registry, \Magento\Weee\Helper\Data $weeeData, \Magento\Tax\Helper\Data $taxData)
execute(Observer $observer)
getWhichCalcPriceToUse($storeId=null, $weeeAttributesForBundle=null)