Chore: Updating Box Now controllers, updates to product indexer for recommended products
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Modules\Core\Catalog\Recommendations;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Lunar\Facades\ModelManifest;
|
||||
use Lunar\Models\Contracts\Product as ProductContract;
|
||||
use Lunar\Models\Product;
|
||||
use Modules\Core\Catalog\Contracts\RecommendationRule;
|
||||
|
||||
@@ -18,7 +20,14 @@ class RandomRule implements RecommendationRule
|
||||
{
|
||||
public function recommend(Product $product, int $limit, array $exclude): Collection
|
||||
{
|
||||
return Product::query()
|
||||
// ModelManifest::get(), not Product::query() directly — the base
|
||||
// Lunar\Models\Product has no custom_fields cast/fillable entry
|
||||
// (see Catalog\Models\Product's own docblock), so a recommendation
|
||||
// resolved as the base class silently lost that field once
|
||||
// ProductIndexer started reading it for recommendations.has_custom_fields.
|
||||
$model = ModelManifest::get(ProductContract::class);
|
||||
|
||||
return $model::query()
|
||||
->whereKeyNot($exclude)
|
||||
->inRandomOrder()
|
||||
->limit($limit)
|
||||
|
||||
Reference in New Issue
Block a user