0

How magento 2 displayed only the in-stock upsell products in view page. How they handled and displayed

I wish to display upsell product collection in list page on each product. I got the upsell product collection using below code and I got the upsell product collection (But it got both in-stock and out of stock products). I need to display only instock upsell products. So Please Provide me a solution to get in-stock upsell products

$product->getUpSellProductCollection()

but while getting collection itself ,how do i add stock status filter then wish to get the upsell collection.

I don't want foreach each item and check stock status

2
  • Add more details and provide more explanation. Add code and methods, you are trying
    – Jarnail S
    Commented Jun 13, 2018 at 6:00
  • why you haven't put these details earlier while adding the question.learn how to put questions in stack Commented Jun 13, 2018 at 6:17

1 Answer 1

0

Handle Upsell Products

  • Open product in Edit mode in the admin page. Then under the Advance setting section, find Up-sell Section.

upsell

  • Now you start to add Up-sell products to the product you open above in Edit mode.

  • Tap Reset Filter in the upper-right corner to display all the available product to choose as Up-sell. Use Filter tool if it’s necessary.

  • After you are done choosing, remember to Save.

Displayed only the In Stock Upsell Products

Go to admin > Stores > configuration > Catalog > Inventory > Stock Options

Set Display Out of Stock Products to NO

out of stock

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.