← All changes
|
includes/Admin/Product/Data/ProductDataFacade.php
+13
-7
1.10.9
→
1.10.21
View file →
| @@ -10,8 +10,9 @@ | ||
| 10 | 10 | use SyncBasalam\Admin\Product\ProductDataFactory; |
| 11 | 11 | use SyncBasalam\Admin\Settings\SettingsConfig; |
| 12 | 12 | use SyncBasalam\Admin\Settings\SettingsManager; |
| 13 | 13 | use SyncBasalam\Jobs\Exceptions\NonRetryableException; |
| 14 | +use SyncBasalam\Services\VendorSyncPolicy; | |
| 14 | 15 | use SyncBasalam\Utilities\ProductMetaKey; |
| 15 | 16 | |
| 16 | 17 | defined('ABSPATH') || exit; |
| 17 | 18 | |
| @@ -47,19 +48,24 @@ | ||
| 47 | 48 | $isUpdate = !empty($basalamProductId); |
| 48 | 49 | |
| 49 | 50 | $settings = SettingsManager::getSettings(); |
| 50 | 51 | $syncFields = $settings[SettingsConfig::SYNC_PRODUCT_FIELDS] ?? 'all'; |
| 52 | + $vendorSyncPolicy = syncBasalamContainer()->get(VendorSyncPolicy::class); | |
| 51 | 53 | |
| 52 | - if ($isUpdate && !SettingsManager::isProductUpdateSelectionValid($settings)) { | |
| 54 | + if ( | |
| 55 | + $isUpdate | |
| 56 | + && !$vendorSyncPolicy->shouldRestrictUpdateFields(false) | |
| 57 | + && !SettingsManager::isProductUpdateSelectionValid($settings) | |
| 58 | + ) { | |
| 53 | 59 | throw NonRetryableException::invalidData(SettingsConfig::CUSTOM_PRODUCT_UPDATE_REQUIRED_MESSAGE); |
| 54 | 60 | } |
| 55 | 61 | |
| 56 | - $strategy = 'create'; | |
| 57 | - if ($isUpdate) { | |
| 58 | - if ($syncFields === 'price_stock') $strategy = 'quick_update'; | |
| 59 | - elseif ($syncFields === 'custom') $strategy = 'custom_update'; | |
| 60 | - else $strategy = 'update'; | |
| 61 | - } | |
| 62 | + $strategy = 'create'; | |
| 63 | + if ($isUpdate) { | |
| 64 | + if ($vendorSyncPolicy->shouldRestrictUpdateFields() || $syncFields === 'price_stock') $strategy = 'quick_update'; | |
| 65 | + elseif ($syncFields === 'custom') $strategy = 'custom_update'; | |
| 66 | + else $strategy = 'update'; | |
| 67 | + } | |
| 62 | 68 | |
| 63 | 69 | return self::$builder |
| 64 | 70 | ->reset() |
| 65 | 71 | ->setStrategy(self::$factory->createStrategy($strategy)) |