0

I'm working with Magento 2, I have one product in cart and I want to show related products for cart products. I get current product using the quote to get all items. Once I have fetched current product's ID and object. Now, I want show related products using current product. Below is my code.

$relatedProducts = $currentProduct->getRelatedProducts();

I am able to get related products using above code, but related product showing by created product ID using my above code. I want show related products based on selection of related product. I want show first two selected related products from related 10 products. Is there any way to get first selected related products not by ID

  • could you explain this , " But I want show related products based on selection of related product. I want show first two selected related products from related 10 products." ? as per my understanding you want related products of currently added item's related product ? – Naveed Asim Mar 29 '18 at 18:42
  • Currently i got related products listing but related products listing is based on created date. But I want related products listing that means ordering based on first selected related products . I have three product name for product is product1, product2,product3 three product content ids 2,4,6. And I have selected product3, then product2 and then product1. After selected this ordering I got results product1, product2, product3 the result is come based on created date orderby Ids. But I want result based on first selection related products that results will be product3, product2,prod – Web developer Mar 30 '18 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.