Skip to content

Commit 25ebfb8

Browse files
authored
Merge pull request #8653 from magento-l3/Tier4-PR-Delivery-12-1-23
Tier4-PR-Delivery-12-1-23
2 parents 2a55516 + c1bc775 commit 25ebfb8

File tree

37 files changed

+910
-445
lines changed

37 files changed

+910
-445
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ public function getNewEmptyItem()
316316
public function addPriceFilter($product, $searchMin, $useRegularPrice = false)
317317
{
318318
if ($product->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
319+
if (!$this->getStoreId()) {
320+
$this->setStoreId($this->_storeManager->getStore()->getId());
321+
}
319322
$this->addPriceData();
320323
if ($useRegularPrice) {
321324
$minimalPriceExpression = self::INDEX_TABLE_ALIAS . '.price';

app/code/Magento/Bundle/Pricing/Price/SpecialPrice.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getValue()
4343
}
4444

4545
$specialPrice = $this->getDiscountPercent();
46-
if ($specialPrice) {
46+
if ($specialPrice !== false) {
4747
$regularPrice = $this->getRegularPrice();
4848
$this->value = $regularPrice * ($specialPrice / 100);
4949
} else {
@@ -63,6 +63,8 @@ protected function getRegularPrice()
6363
}
6464

6565
/**
66+
* Returns true as special price is always percentage for bundle products
67+
*
6668
* @return bool
6769
*/
6870
public function isPercentageDiscount()

app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ public function getValueDataProvider()
135135
'percent' => 40],
136136
['regularPrice' => 75, 'specialPrice' => 40, 'isScopeDateInInterval' => false, 'value' => false,
137137
'percent' => null],
138+
['regularPrice' => 100, 'specialPrice' => 0, 'isScopeDateInInterval' => true, 'value' => 0,
139+
'percent' => 0],
138140
];
139141
}
140142
}

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1919
use Magento\ImportExport\Model\Import;
2020
use Magento\Store\Model\Store;
21+
use Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType as CatalogImportExportAbstractType;
2122
use Magento\Store\Model\StoreManagerInterface;
2223

2324
/**
@@ -26,7 +27,7 @@
2627
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2728
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2829
*/
29-
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType implements
30+
class Bundle extends CatalogImportExportAbstractType implements
3031
ResetAfterRequestInterface
3132
{
3233
/**
@@ -339,6 +340,31 @@ protected function populateSelectionTemplate($selection, $optionId, $parentId, $
339340
return $populatedSelection;
340341
}
341342

343+
/**
344+
* Set cache option selection
345+
*
346+
* @param array $existingSelection
347+
* @param string $optionTitle
348+
* @param string $selectIndex
349+
* @param string $key
350+
* @param string $origKey
351+
* @return void
352+
*/
353+
private function setCacheOptionSelection(
354+
array $existingSelection,
355+
string $optionTitle,
356+
string $selectIndex,
357+
string $key,
358+
string $origKey
359+
): void {
360+
if (!isset($this->_cachedOptions[$existingSelection['parent_product_id']]
361+
[$optionTitle]['selections'][$selectIndex][$key])
362+
) {
363+
$this->_cachedOptions[$existingSelection['parent_product_id']]
364+
[$optionTitle]['selections'][$selectIndex][$key] = $existingSelection[$origKey];
365+
}
366+
}
367+
342368
/**
343369
* Deprecated method for retrieving mapping between skus and products.
344370
*
@@ -353,7 +379,7 @@ protected function retrieveProducsByCachedSkus()
353379
/**
354380
* Retrieve mapping between skus and products.
355381
*
356-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
382+
* @return CatalogImportExportAbstractType
357383
*/
358384
protected function retrieveProductsByCachedSkus()
359385
{
@@ -372,7 +398,7 @@ protected function retrieveProductsByCachedSkus()
372398
/**
373399
* Save product type specific data.
374400
*
375-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
401+
* @return CatalogImportExportAbstractType
376402
*/
377403
public function saveData()
378404
{
@@ -476,7 +502,7 @@ protected function transformBundleCustomAttributes($rowData)
476502
/**
477503
* Populates existing options.
478504
*
479-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
505+
* @return CatalogImportExportAbstractType
480506
*/
481507
protected function populateExistingOptions()
482508
{
@@ -515,7 +541,9 @@ protected function populateExistingOptions()
515541
*
516542
* @param array $existingOptions
517543
*
518-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
544+
* @return CatalogImportExportAbstractType
545+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
546+
* @SuppressWarnings(PHPMD.NPathComplexity)
519547
*/
520548
protected function populateExistingSelections($existingOptions)
521549
{
@@ -530,20 +558,18 @@ protected function populateExistingSelections($existingOptions)
530558
);
531559
foreach ($existingSelections as $existingSelection) {
532560
$optionTitle = $existingOptions[$existingSelection['option_id']]['title'];
533-
$cachedOptionsSelections = $this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'];
534-
foreach ($cachedOptionsSelections as $selectIndex => $selection) {
535-
$productId = $this->_cachedSkuToProducts[$selection['sku']];
536-
if ($productId == $existingSelection['product_id']) {
537-
foreach (array_keys($existingSelection) as $origKey) {
538-
$key = $this->_bundleFieldMapping[$origKey] ?? $origKey;
539-
if (
540-
!isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key])
541-
) {
542-
$this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key] =
543-
$existingSelection[$origKey];
561+
if (array_key_exists($existingSelection['parent_product_id'], $this->_cachedOptions)) {
562+
$cachedOptionsSelections = $this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'];
563+
foreach ($cachedOptionsSelections as $selectIndex => $selection) {
564+
$productId = $this->_cachedSkuToProducts[$selection['sku']];
565+
if ($productId == $existingSelection['product_id']) {
566+
foreach (array_keys($existingSelection) as $origKey) {
567+
$key = $this->_bundleFieldMapping[$origKey] ?? $origKey;
568+
$this->setCacheOptionSelection($existingSelection, (string) $optionTitle,
569+
(string) $selectIndex, (string) $key, (string) $origKey);
544570
}
571+
break;
545572
}
546-
break;
547573
}
548574
}
549575
}
@@ -554,7 +580,7 @@ protected function populateExistingSelections($existingOptions)
554580
/**
555581
* Insert options.
556582
*
557-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
583+
* @return CatalogImportExportAbstractType
558584
*/
559585
protected function insertOptions()
560586
{
@@ -630,7 +656,7 @@ protected function populateInsertOptionValues(array $optionIds): array
630656
/**
631657
* Insert selections.
632658
*
633-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
659+
* @return CatalogImportExportAbstractType
634660
*/
635661
protected function insertSelections()
636662
{
@@ -664,7 +690,7 @@ protected function insertSelections()
664690
/**
665691
* Insert parent/child product relations
666692
*
667-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
693+
* @return CatalogImportExportAbstractType
668694
*/
669695
private function insertParentChildRelations()
670696
{
@@ -720,7 +746,7 @@ protected function _initAttributes()
720746
*
721747
* @param array $productIds
722748
*
723-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
749+
* @return CatalogImportExportAbstractType
724750
*/
725751
protected function deleteOptionsAndSelections($productIds)
726752
{
@@ -762,7 +788,7 @@ protected function deleteOptionsAndSelections($productIds)
762788
/**
763789
* Clear cached values between bunches
764790
*
765-
* @return \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
791+
* @return CatalogImportExportAbstractType
766792
*/
767793
protected function clear()
768794
{

app/code/Magento/Catalog/Api/ProductAttributeIsFilterableManagementInterface.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<?php
22
/************************************************************************
33
*
4-
* ADOBE CONFIDENTIAL
5-
* ___________________
6-
*
7-
* Copyright 2014 Adobe
4+
* Copyright 2023 Adobe
85
* All Rights Reserved.
96
*
107
* NOTICE: All information contained herein is, and remains

app/code/Magento/Catalog/Block/Product/View/Options.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
/**
1313
* Product options block
1414
*
15-
* @author Magento Core Team <[email protected]>
1615
* @api
1716
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1817
* @since 100.0.2
@@ -39,7 +38,7 @@ class Options extends \Magento\Framework\View\Element\Template
3938
protected $_registry = null;
4039

4140
/**
42-
* Catalog product
41+
* Product
4342
*
4443
* @var Product
4544
*/
@@ -175,7 +174,17 @@ protected function _getPriceConfiguration($option)
175174
$data = [
176175
'prices' => [
177176
'oldPrice' => [
178-
'amount' => $this->pricingHelper->currency($option->getRegularPrice(), false, false),
177+
'amount' => $this->_catalogData->getTaxPrice(
178+
$option->getProduct(),
179+
$option->getRegularPrice(),
180+
true,
181+
null,
182+
null,
183+
null,
184+
null,
185+
null,
186+
false
187+
),
179188
'adjustments' => [],
180189
],
181190
'basePrice' => [

app/code/Magento/Catalog/Cron/SynchronizeWebsiteAttributes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Magento\Catalog\Model\ResourceModel\Attribute\WebsiteAttributesSynchronizer;
1010

1111
/**
12-
* Class SynchronizeWebsiteAttributes
13-
* @package Magento\Catalog\Cron
12+
* @deprecated
13+
* @see \Magento\Catalog\Model\Attribute\Backend\WebsiteSpecific\ValueSynchronizer
1414
*/
1515
class SynchronizeWebsiteAttributes
1616
{
@@ -20,7 +20,6 @@ class SynchronizeWebsiteAttributes
2020
private $synchronizer;
2121

2222
/**
23-
* SynchronizeWebsiteAttributes constructor.
2423
* @param WebsiteAttributesSynchronizer $synchronizer
2524
*/
2625
public function __construct(WebsiteAttributesSynchronizer $synchronizer)
@@ -30,6 +29,7 @@ public function __construct(WebsiteAttributesSynchronizer $synchronizer)
3029

3130
/**
3231
* Synchronizes website attribute values if needed
32+
*
3333
* @return void
3434
*/
3535
public function execute()
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* ADOBE CONFIDENTIAL
4+
*
5+
* Copyright 2023 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Catalog\Model\Attribute\Backend\WebsiteSpecific;
20+
21+
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
22+
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
23+
use Magento\Framework\Bulk\BulkManagementInterface;
24+
use Magento\Framework\DataObject\IdentityGeneratorInterface;
25+
use Magento\Framework\Exception\LocalizedException;
26+
use Magento\Framework\Serialize\SerializerInterface;
27+
28+
class Scheduler
29+
{
30+
private const TOPIC_NAME = 'catalog_website_attribute_value_sync';
31+
32+
/**
33+
* @param BulkManagementInterface $bulkManagement
34+
* @param IdentityGeneratorInterface $identityGenerator
35+
* @param OperationInterfaceFactory $operationFactory
36+
* @param SerializerInterface $serializer
37+
*/
38+
public function __construct(
39+
private BulkManagementInterface $bulkManagement,
40+
private IdentityGeneratorInterface $identityGenerator,
41+
private OperationInterfaceFactory $operationFactory,
42+
private SerializerInterface $serializer
43+
) {
44+
}
45+
46+
/**
47+
* Schedule website specific values synchronization.
48+
*
49+
* @param int $storeId
50+
* @return void
51+
* @throws LocalizedException
52+
*/
53+
public function execute(int $storeId): void
54+
{
55+
$bulkUuid = $this->identityGenerator->generateId();
56+
$operation = $this->operationFactory->create(
57+
[
58+
'data' => [
59+
'bulk_uuid' => $bulkUuid,
60+
'topic_name' => self::TOPIC_NAME,
61+
'serialized_data' => $this->serializer->serialize(['store_id' => $storeId]),
62+
'status' => OperationInterface::STATUS_TYPE_OPEN,
63+
]
64+
]
65+
);
66+
$bulkDescription = __('Synchronize website specific attributes values');
67+
$result = $this->bulkManagement->scheduleBulk($bulkUuid, [$operation], $bulkDescription);
68+
if (!$result) {
69+
throw new LocalizedException(__('Something went wrong while scheduling operations.'));
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)