Jump to content

Exclude out of stock products from cross selling module


AcidLava

Recommended Posts

Hello,

elsewhere you said that you are setting visibility for out of stock products to `none` so you can try to modify the PHP code of the module changing:

AND product_shop.active = 1

to:

AND product_shop.active = 1 AND product_shop.visibility != \'none\'

Of course to make it correctly, it should be done with a module override, but for first testing you can change it directly in the module and see if it works.

Link to comment
Share on other sites

Hello,

I tried but out of stock products still display.

            $order_products = Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS('
                SELECT DISTINCT od.product_id
                FROM ' . _DB_PREFIX_ . 'order_detail od
                LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = od.product_id)
                ' . Shop::addSqlAssociation('product', 'p') .
                $sql_groups_join . '
                WHERE od.id_order IN (' . $list . ')
                AND od.product_id NOT IN (' . $list_product_ids . ')
                AND product_shop.visibility IN (\'both\',\'catalog\')
                AND product_shop.active = 1 AND product_shop.visibility != \'none\'
                ' . $sql_groups_where . '
                ORDER BY RAND()
                LIMIT ' . (int) Configuration::get('CROSSSELLING_NBR')
            );
        }

 

Link to comment
Share on other sites

 I just noticed that the is already that line there:

AND product_shop.visibility IN (\'both\',\'catalog\')

AND product_shop.visibility IN (\'both\',\'catalog\')

So no changes should be required as long as your out of stock products have visibility set to 'none', so you need to make sure they do.

Link to comment
Share on other sites

After this change, a product with its visibility set to 'catalog' should be excluded from the cross-selling module. Please double-check by taking a product that is incorrectly displayed there and verifying its visibility setting.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...