← All changes
|
includes/Admin/Product/Operations/UpdateProduct.php
+11
-4
1.9.2
→
1.10.19
View file →
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace SyncBasalam\Admin\Product\Operations; |
| 4 | 4 | |
| @@ -5,9 +5,11 @@ | ||
| 5 | 5 | use SyncBasalam\Admin\Product\Operations\AbstractProductOperation; |
| 6 | 6 | use SyncBasalam\Services\Products\UpdateSingleProductService; |
| 7 | 7 | use SyncBasalam\Admin\Product\Data\ProductDataFacade; |
| 8 | 8 | use SyncBasalam\Logger\Logger; |
| 9 | -use SyncBasalam\Services\Products\Discount\DiscountTaskProcessor; | |
| 9 | +use SyncBasalam\Services\Products\Discount\DiscountTaskProcessor; | |
| 10 | +use SyncBasalam\Jobs\Exceptions\NonRetryableException; | |
| 11 | +use SyncBasalam\Services\VendorSyncPolicy; | |
| 10 | 12 | |
| 11 | 13 | defined('ABSPATH') || exit; |
| 12 | 14 | |
| 13 | 15 | class UpdateProduct extends AbstractProductOperation |
| @@ -25,11 +27,16 @@ | ||
| 25 | 27 | $this->discountProcessor = $discountProcessor ?: syncBasalamContainer()->get(DiscountTaskProcessor::class); |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | 30 | |
| 29 | - protected function run(int $productId, array $args = []): array | |
| 30 | - { | |
| 31 | - $categoryIds = $args['category_ids'] ?? null; | |
| 31 | + protected function run(int $productId, array $args = []): array | |
| 32 | + { | |
| 33 | + $vendorSyncPolicy = syncBasalamContainer()->get(VendorSyncPolicy::class); | |
| 34 | + if (!$vendorSyncPolicy->canUpdate()) { | |
| 35 | + throw NonRetryableException::invalidData($vendorSyncPolicy->getRestrictionMessage(false)); | |
| 36 | + } | |
| 37 | + | |
| 38 | + $categoryIds = $args['category_ids'] ?? null; | |
| 32 | 39 | |
| 33 | 40 | $productData = ProductDataFacade::get($productId, $categoryIds); |
| 34 | 41 | |
| 35 | 42 | $updateResult = $this->updateProductService->updateProductInBasalam($productData, $productId); |