How to override the product stock status behaviour based on custom product attribute

by user2213139   Last Updated January 13, 2018 02:09 AM

Am using Magento2 CE 2.1.10

A custom boolean attribute (global scope) has been added, attribute code "custom_force_on_web" with default value of false.

Desired outcome is that an out of stock product (either inventory quantity is zero and/or its' status is set to "Out of Stock") be visible in its parent category page (frontend) and any category search filters results if "custom_force_on_web" is true for a given product.

By "category search filters" I'm referring to what you see under "Shopping Options" when on the frontend category page.

Native Magento2 behaviour is to exclude "Out of Stock" products in category page and in any category search. Native Magento2 does allow to show "Out of Stock" products but only as a global yes/no option for all products. What I need is the ability to apply this at/on the product level, via the custom attribute.

This is required by my employers' customer, there's no wiggle room.

I have already googled this subject, traced the Catalog, CatalogInventory and CatalogSearch modules, and official Magento2 documentation.

I have discussed this in the official Magento2 irc channel.

Basically no one knows how to do this.

Any help would be greatly appreciated.

Tags : magento2


Related Questions


Cart Price Rules having issues

Updated October 01, 2018 18:09 PM


Magento 2.2 Not Loading theme and blocks

Updated January 11, 2018 02:09 AM