|
14 | 14 | use Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap;
|
15 | 15 | use Magento\Catalog\Model\ProductRepository\MediaGalleryProcessor;
|
16 | 16 | use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
| 17 | +use Magento\CatalogUrlRewrite\Block\UrlKeyRenderer; |
17 | 18 | use Magento\Eav\Model\Entity\Attribute\Exception as AttributeException;
|
18 | 19 | use Magento\Framework\Api\Data\ImageContentInterfaceFactory;
|
19 | 20 | use Magento\Framework\Api\ImageContentValidatorInterface;
|
20 | 21 | use Magento\Framework\Api\ImageProcessorInterface;
|
21 | 22 | use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
|
22 | 23 | use Magento\Framework\Api\SearchCriteriaInterface;
|
| 24 | +use Magento\Framework\App\Config\ScopeConfigInterface; |
23 | 25 | use Magento\Framework\DB\Adapter\ConnectionException;
|
24 | 26 | use Magento\Framework\DB\Adapter\DeadlockException;
|
25 | 27 | use Magento\Framework\DB\Adapter\LockWaitException;
|
|
32 | 34 | use Magento\Framework\Exception\TemporaryState\CouldNotSaveException as TemporaryCouldNotSaveException;
|
33 | 35 | use Magento\Framework\Exception\ValidatorException;
|
34 | 36 | use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
|
| 37 | +use Magento\Store\Model\ScopeInterface; |
35 | 38 | use Magento\Store\Model\Store;
|
36 | 39 | use Magento\Catalog\Api\Data\EavAttributeInterface;
|
37 | 40 |
|
@@ -187,6 +190,11 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
|
187 | 190 | */
|
188 | 191 | private $scopeOverriddenValue;
|
189 | 192 |
|
| 193 | + /** |
| 194 | + * @var ScopeConfigInterface |
| 195 | + */ |
| 196 | + private ScopeConfigInterface $scopeConfig; |
| 197 | + |
190 | 198 | /**
|
191 | 199 | * ProductRepository constructor.
|
192 | 200 | * @param ProductFactory $productFactory
|
@@ -214,6 +222,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
|
214 | 222 | * @param ReadExtensions $readExtensions
|
215 | 223 | * @param CategoryLinkManagementInterface $linkManagement
|
216 | 224 | * @param ScopeOverriddenValue|null $scopeOverriddenValue
|
| 225 | + * @param ScopeConfigInterface|null $scopeConfig |
217 | 226 | * @SuppressWarnings(PHPMD.ExcessiveParameterList)
|
218 | 227 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
219 | 228 | */
|
@@ -242,7 +251,8 @@ public function __construct(
|
242 | 251 | $cacheLimit = 1000,
|
243 | 252 | ?ReadExtensions $readExtensions = null,
|
244 | 253 | ?CategoryLinkManagementInterface $linkManagement = null,
|
245 |
| - ?ScopeOverriddenValue $scopeOverriddenValue = null |
| 254 | + ?ScopeOverriddenValue $scopeOverriddenValue = null, |
| 255 | + ?ScopeConfigInterface $scopeConfig = null |
246 | 256 | ) {
|
247 | 257 | $this->productFactory = $productFactory;
|
248 | 258 | $this->collectionFactory = $collectionFactory;
|
@@ -270,6 +280,8 @@ public function __construct(
|
270 | 280 | ->get(CategoryLinkManagementInterface::class);
|
271 | 281 | $this->scopeOverriddenValue = $scopeOverriddenValue ?: \Magento\Framework\App\ObjectManager::getInstance()
|
272 | 282 | ->get(ScopeOverriddenValue::class);
|
| 283 | + $this->scopeConfig = $scopeConfig ?: \Magento\Framework\App\ObjectManager::getInstance() |
| 284 | + ->get(ScopeConfigInterface::class);; |
273 | 285 | }
|
274 | 286 |
|
275 | 287 | /**
|
@@ -649,6 +661,14 @@ public function save(ProductInterface $product, $saveOptions = false)
|
649 | 661 | }
|
650 | 662 | }
|
651 | 663 |
|
| 664 | + $isSaveHistory = $this->scopeConfig->isSetFlag( |
| 665 | + UrlKeyRenderer::XML_PATH_SEO_SAVE_HISTORY, |
| 666 | + ScopeInterface::SCOPE_STORE, |
| 667 | + $productDataArray['store_id'] |
| 668 | + ); |
| 669 | + |
| 670 | + $product->setData('save_rewrites_history', $isSaveHistory); |
| 671 | + |
652 | 672 | $this->saveProduct($product);
|
653 | 673 | if ($assignToCategories === true && $product->getCategoryIds()) {
|
654 | 674 | $this->linkManagement->assignProductToCategories(
|
|
0 commit comments