gangiaemi Posted May 16, 2011 Share Posted May 16, 2011 Ciao a tutti,ho una richiesta di aiuto.Vorrei poter fare questa cosa qui : quando clicco sulla categoria (menu a sinistra), visualizzo ora tutti i prodotti di quella categoria.Ho trovato la query che mi fa visualizzare tutti i prodotti della categoria selezionata : $sql = ' SELECT p.*, pa.`id_product_attribute`, 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`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, cl.`name` AS category_default, DATEDIFF(p.`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, (p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1) - IF((DATEDIFF(`reduction_from`, CURDATE()) <= 0 AND DATEDIFF(`reduction_to`, CURDATE()) >=0) OR `reduction_from` = `reduction_to`, IF(`reduction_price` > 0, `reduction_price`, (p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1) * `reduction_percent` / 100)),0)) AS orderprice FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1) LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'tax` t ON t.`id_tax` = p.`id_tax` LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE cp.`id_category` = '.intval($this->id).($active ? ' AND p.`active` = 1' : '').' '.($id_supplier ? 'AND p.id_supplier = '.$id_supplier : ''; Vorrei fare in modo da poter visualizzare i prodotti che appartengono solo ad un particolare gruppo/attributo , ad esempio Gruppo :materiale, Attributo : Oro.E' possibile agire su questa query facendo un append in modo tale che riesca a vedere solo i prodotti appartenenti a quella categoria , con gruppo e attributo settato?Qualcuno mi puo aiutare per favore?Per favore rispondete Grazie a tutti per la disponibilità e per qualsiasi aiuto verrà ricevuto.Ciao ciaoE. Link to comment Share on other sites More sharing options...
gangiaemi Posted May 21, 2011 Author Share Posted May 21, 2011 Ciao,sono riuscito a risolvere il problema.Spero che possa servire a qualcuno .Inserisco la query per la versione 1.3.7 di prestashop. SELECT p.id_product, p.out_of_stock, p.quantity, p.id_category_default, p.customizable, p.price, p.`weight`, p.ean13, pl.available_later, pl.description_short, pl.link_rewrite, pl.name, i.id_image, il.legend, m.name manufacturer_name, p.id_manufacturer, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL 20 DAY)) > 0 AS new FROM ps_product p LEFT JOIN ps_product_lang pl ON (pl.id_product = p.id_product) LEFT JOIN ps_image i ON (i.id_product = p.id_product AND i.cover = 1) LEFT JOIN ps_image_lang il ON (i.id_image = il.id_image AND il.id_lang = 1) LEFT JOIN ps_manufacturer m ON (m.id_manufacturer = p.id_manufacturer) WHERE pl.id_lang = 1 AND p.id_product IN ( SELECT id_product FROM ps_category_product cp WHERE 1 AND cp.`id_category` = 2 OR cp.`id_category` = 2) AND p.id_product IN ( SELECT pa.`id_product` FROM `ps_product_attribute_combination` pac LEFT JOIN `ps_product_attribute` pa ON (pa.`id_product_attribute` = pac.`id_product_attribute`) WHERE pac.`id_attribute` = 21) AND p.id_product IN ( SELECT pa.`id_product` FROM `ps_product_attribute_combination` pac LEFT JOIN `ps_product_attribute` pa ON (pa.`id_product_attribute` = pac.`id_product_attribute`) WHERE pac.`id_attribute` =27 id_attribute = 27 ed id_attribute=21 rappresentano rispettivamente il mio prodotto in ORO della linea ANELLI.Grazie a tutti per la disponibilità.A presto.E. 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