How can i display related product items ?

How can i display related product items ?

Laraship QuestionsCategory: TechnicalHow can i display related product items ?
phat.pham asked 10 months ago
Hello,
In Ecommerce Ultimate theme, how could i display related products “You May Also Like” ? I attached a screenshot for more detail.
Thank you.
Attachments

1 Answers
laraship Staff answered 10 months ago
Hello,
You can use
[crayon-5f098cda20318131548189/]
phat.pham
replied 10 months ago

Hello,

Thanks for this info.
I tried to see the Shop class with your suggested function, as it’s attached below:

The path of Shop class, Corals/modules/Ecommerce/Classes/Shop.php

———–
public function getCategoryAvailableProducts($category_id, $count = false)
{
$products = Product::has(‘activeSKU’, ‘>=’, 1)
->where(‘ecommerce_products.status’, ‘active’);

$products = $this->categoryQueryBuilderFilter($products, $category_id);

if ($count) {
$products = $products->count();
} else {
$products = $products->select(‘ecommerce_products.*’)->paginate($this->page_limit);
}

return $products;
}
————-

And another definition on the same file, but it’s commented:

————-
// $categories = $categories->map(function ($category, $key) {
// $category[‘products_count’] = $this->getCategoryAvailableProducts($category->id, true);
// return $category;
// });

————-

How could i make the “related product” works?

Thank you.

70% OFF

No Minimum, No Exceptions
 
GO TO STORE
close-link