PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.19
ووسلام – همگام سازی ووکامرس و باسلام v1.10.19
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
← All changes | includes/Admin/Product/Operations/CreateProduct.php +11 -4 1.10.21.10.19 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2
3 3 namespace SyncBasalam\Admin\Product\Operations;
4 4
@@ -6,9 +6,11 @@
6 6 use SyncBasalam\Services\Products\CreateSingleProductService;
7 7 use SyncBasalam\Services\Products\Discount\DiscountTaskProcessor;
8 8 use SyncBasalam\Logger\Logger;
9 9 use SyncBasalam\Admin\Product\Data\ProductDataFacade;
10 -use SyncBasalam\Utilities\ProductMetaKey;
10 +use SyncBasalam\Utilities\ProductMetaKey;
11 +use SyncBasalam\Jobs\Exceptions\NonRetryableException;
12 +use SyncBasalam\Services\VendorSyncPolicy;
11 13
12 14 defined('ABSPATH') || exit;
13 15
14 16 class CreateProduct extends AbstractProductOperation
@@ -26,11 +28,16 @@
26 28 $this->discountProcessor = $discountProcessor ?: syncBasalamContainer()->get(DiscountTaskProcessor::class);
27 29 }
28 30
29 31
30 - protected function run(int $product_id, array $args = []): array
31 - {
32 - $categoryIds = $args['category_ids'] ?? [];
32 + protected function run(int $product_id, array $args = []): array
33 + {
34 + $vendorSyncPolicy = syncBasalamContainer()->get(VendorSyncPolicy::class);
35 + if (!$vendorSyncPolicy->canCreate()) {
36 + throw NonRetryableException::invalidData($vendorSyncPolicy->getRestrictionMessage(false));
37 + }
38 +
39 + $categoryIds = $args['category_ids'] ?? [];
33 40
34 41 $productData = ProductDataFacade::get($product_id, $categoryIds);
35 42
36 43 $createResult = $this->createProductService->createProductInBasalam($productData, $product_id);