renato4788 Posted July 15, 2014 Share Posted July 15, 2014 (edited) Preciso achar uma solução para exibir os produtos que estão fora de estoque por ultimo. E uma segunda ordenação seguindo a ecolha do cliente. Alguém ja conseguiu fazer isso, ou tem conhecimento de um módulo para isso. Desde já agradeço a atenção. Edited August 1, 2014 by renato4788 (see edit history) Link to comment Share on other sites More sharing options...
Daniel - PrestaBR Posted July 15, 2014 Share Posted July 15, 2014 Precisa alterar a(s) classe(s) e depende da versão do PrestaShop, mas a ideia é essa: http://www.prestashop.com/forums/topic/201563-solvedsort-products-by-price-and-put-out-of-stock-products-at-the-end-of-list/ Link to comment Share on other sites More sharing options...
renato4788 Posted July 17, 2014 Author Share Posted July 17, 2014 Consegui resolver, editei o o arquivo classes/Category.php na linha 615 ficou assim $sql = 'SELECT SIGN(stock.quantity) as estoqueDisponivel, p.* - segue igual.. e na linha 656 : $sql .= ' ORDER BY estoqueDisponivel desc, ' - segue igual. A versão do prestashop que uso é a 1.5.6.2 ... o numero da linha pode mudar de acordo com a versão. Com essa mudança quando acesso a página de uma categoria, por default os produtos que tem quantidade 0 ficam por ultimo e a segunda ordenação segue a que eu escolhi no sitema. Abraço a todos. $sql = 'SELECT SIGN(stock.quantity) as estoqueDisponivel, p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new, product_shop.price AS orderprice FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').' '.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop).' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').') LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE product_shop.`id_shop` = '.(int)$context->shop->id.' AND cp.`id_category` = '.(int)$this->id .($active ? ' AND product_shop.`active` = 1' : '') .($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') .($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '') .' GROUP BY product_shop.id_product'; if ($random === true) { $sql .= ' ORDER BY RAND()'; $sql .= ' LIMIT 0, '.(int)$random_number_products; } else $sql .= ' ORDER BY estoqueDisponivel desc, '.(isset($order_by_prefix) ? $order_by_prefix.'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); if ($order_by == 'orderprice') Tools::orderbyPrice($result, $order_way); if (!$result) return array(); /* Modify SQL result */ return Product::getProductsProperties($id_lang, $result); } 1 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