fix bug
This commit is contained in:
@@ -191,9 +191,7 @@ class ProductController extends SuperController
|
|||||||
$products = $categoryService->sortProductsForStore($products);
|
$products = $categoryService->sortProductsForStore($products);
|
||||||
|
|
||||||
if (str_contains(request()->path(), '/customer/')) {
|
if (str_contains(request()->path(), '/customer/')) {
|
||||||
$products->each(function (Product $product) {
|
$this->applyCustomerShow($products);
|
||||||
$product->setAttribute('show', $this->storeProductShowForCustomer($product));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($products);
|
return response()->json($products);
|
||||||
@@ -203,12 +201,7 @@ class ProductController extends SuperController
|
|||||||
$products = Product::with(['file'])->where('active', 1)->get();
|
$products = Product::with(['file'])->where('active', 1)->get();
|
||||||
|
|
||||||
if (str_contains(request()->path(), '/customer/')) {
|
if (str_contains(request()->path(), '/customer/')) {
|
||||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
$this->applyCustomerShow($products);
|
||||||
$displayPriceService->warmLivePriceCache();
|
|
||||||
$displayPriceService->enrichForApi($products);
|
|
||||||
$products->each(function (Product $product) use ($displayPriceService) {
|
|
||||||
$product->setAttribute('show', $displayPriceService->resolveCustomerShow($product));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) {
|
if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) {
|
||||||
@@ -231,10 +224,18 @@ class ProductController extends SuperController
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($product) {
|
if ($product) {
|
||||||
|
if (str_contains(request()->path(), '/customer/')) {
|
||||||
|
$this->applyCustomerShow(collect([$product]));
|
||||||
|
}
|
||||||
|
|
||||||
$product->similar = Product::with(['file'])
|
$product->similar = Product::with(['file'])
|
||||||
->where('group_type', $product->group_type)
|
->where('group_type', $product->group_type)
|
||||||
->where('id', '!=', $id)
|
->where('id', '!=', $id)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
if (str_contains(request()->path(), '/customer/')) {
|
||||||
|
$this->applyCustomerShow($product->similar);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return response()->json(false);
|
return response()->json(false);
|
||||||
}
|
}
|
||||||
@@ -378,6 +379,32 @@ class ProductController extends SuperController
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function applyCustomerShow($products): void
|
||||||
|
{
|
||||||
|
$products = $products instanceof \Illuminate\Support\Collection
|
||||||
|
? $products
|
||||||
|
: collect($products);
|
||||||
|
|
||||||
|
if ($products->isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app(ConfigService::class)->isStore()) {
|
||||||
|
$products->each(function (Product $product) {
|
||||||
|
$product->setAttribute('show', $this->storeProductShowForCustomer($product));
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||||
|
$displayPriceService->warmLivePriceCache();
|
||||||
|
$displayPriceService->enrichForApi($products);
|
||||||
|
$products->each(function (Product $product) use ($displayPriceService) {
|
||||||
|
$product->setAttribute('show', $displayPriceService->resolveCustomerShow($product));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private function filterProductData(array $data): array
|
private function filterProductData(array $data): array
|
||||||
{
|
{
|
||||||
if (!Product::hasPriceOffsetColumn()) {
|
if (!Product::hasPriceOffsetColumn()) {
|
||||||
|
|||||||
@@ -174,7 +174,6 @@ class ProductPriceSyncService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$products = Product::query()->whereNotNull('reading_method')->get();
|
$products = Product::query()->whereNotNull('reading_method')->get();
|
||||||
$currentTime = now()->format('H:i:s');
|
|
||||||
$synced = false;
|
$synced = false;
|
||||||
|
|
||||||
foreach ($products as $product) {
|
foreach ($products as $product) {
|
||||||
|
|||||||
Reference in New Issue
Block a user