fix bug 2
This commit is contained in:
@@ -39,6 +39,37 @@ class ProductPriceSyncService
|
||||
$synced = true;
|
||||
}
|
||||
|
||||
if ($this->syncAppPriceProducts()) {
|
||||
$synced = true;
|
||||
}
|
||||
|
||||
return $synced;
|
||||
}
|
||||
|
||||
/** محصولات آبشده با مرجع «قیمت اپ» — ذخیره آخرین قیمت در DB برای fallback */
|
||||
private function syncAppPriceProducts(): bool
|
||||
{
|
||||
$display = app(ProductDisplayPriceService::class);
|
||||
$products = Product::query()
|
||||
->where('active', 1)
|
||||
->get()
|
||||
->filter(static fn (Product $product) => $display->usesAppPrice($product));
|
||||
|
||||
if ($products->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$basePrice = $display->resolveAppBasePrice();
|
||||
if ($basePrice <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$synced = false;
|
||||
foreach ($products as $product) {
|
||||
ProductPriceService::syncFromReference($product, $basePrice, 0);
|
||||
$synced = true;
|
||||
}
|
||||
|
||||
return $synced;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user