Dreamer83 Posted July 20, 2023 Share Posted July 20, 2023 hi i have a problem when i choose accessories (Screenshot_1.png) i would like to see only active product how can i change this? i've not found the js or the controller that manage this choice? thanks Link to comment Share on other sites More sharing options...
ventura Posted July 20, 2023 Share Posted July 20, 2023 It may be necessary to modify/override the query of the function getAccessoriesLight in classes/Product.php Link to comment Share on other sites More sharing options...
Dreamer83 Posted July 20, 2023 Author Share Posted July 20, 2023 i've change this query simply adding AND p.active=1 public static function getAccessoriesLight($id_lang, $id_product) { return Db::getInstance()->executeS( ' SELECT p.`id_product`, p.`reference`, pl.`name` FROM `' . _DB_PREFIX_ . 'accessory` LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON (p.`id_product`= `id_product_2`) ' . Shop::addSqlAssociation('product', 'p') . ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON ( p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . ' ) WHERE `id_product_1` = ' . (int) $id_product.' AND p.`active`= 1' ); } It doesn't work maybe does something wrong? Link to comment Share on other sites More sharing options...
ventura Posted July 20, 2023 Share Posted July 20, 2023 It may not be a good approach search results are retrieved by ajax. controllers/admin/AdminProductsController.php displayAjaxProductsList() Edit the query in the firts $sql variable Link to comment Share on other sites More sharing options...
Dreamer83 Posted July 24, 2023 Author Share Posted July 24, 2023 hi i've edit the $sql adding AND p.active=1 see this: /****************** $sql ='SELECT p.`id_product`, pl.`link_rewrite`, p.`reference`, pl.`name`, image_shop.`id_image` id_image, il.`legend`, p.`cache_default_attribute` FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') . ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (pl.id_product = p.id_product AND pl.id_lang = ' . (int) $context->language->id . Shop::addSqlRestrictionOnLang('pl') . ') LEFT JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $context->shop->id . ') LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $context->language->id . ') WHERE (pl.name LIKE \'%' . pSQL($query) . '%\' OR p.reference LIKE \'%' . pSQL($query) . '%\')' . (!empty($excludeIds) ? ' AND p.active=1 AND p.id_product NOT IN (' . $excludeIds . ') ' : ' ') . ($excludeVirtuals ? 'AND NOT EXISTS (SELECT 1 FROM `' . _DB_PREFIX_ . 'product_download` pd WHERE (pd.id_product = p.id_product))' : '') . ($exclude_packs ? 'AND (p.cache_is_pack IS NULL OR p.cache_is_pack = 0)' : '') . ' GROUP BY p.id_product'; ***************************/ is it correct? Link to comment Share on other sites More sharing options...
ventura Posted July 24, 2023 Share Posted July 24, 2023 Better at the end, eg https://notepad.pw/code/7ekX4x09NXiX3gOf3mIm Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now