sarfaraz.r1406 Posted November 28, 2015 Share Posted November 28, 2015 Hi All, I am trying to create a module which will display all the recently bought items on the home page. I have created the tpl files and the complete module. I able to display all the recently bought items. But the issue I am facing is that the module is not displaying the price information (price, specific price, etc.) It displays all 0. The query I have written is as follows: the variable $results contain the id of all the products recently ordered by the current customer. foreach($results AS $result) { $p[] = $result['product_id']; } $sql = new DbQuery(); $sql->select( 'p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, pl.`available_now`, pl.`available_later`, MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` AS manufacturer_name, product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" as new' ); $sql->from('product', 'p'); $sql->join(Shop::addSqlAssociation('product', 'p')); $sql->leftJoin('product_lang', 'pl', ' p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl') ); $sql->leftJoin('image', 'i', 'i.`id_product` = p.`id_product`'); $sql->join(Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1')); $sql->leftJoin('image_lang', 'il', 'i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang); $sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`'); $sql->where('product_shop.`active` = 1 AND p.`id_product` IN ('.implode(',',$p).')'); if (Group::isFeatureActive()) $sql->where('p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sql_groups.' )'); $sql->groupBy('product_shop.id_product'); if (Combination::isFeatureActive()) { $sql->select('(product_attribute_shop.id_product_attribute) id_product_attribute'); $sql->leftOuterJoin('product_attribute', 'pa', 'pa.`id_product` IN ('.implode(',',$p).')'); $sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.default_on = 1')); } Please help. Thanks in advance. Link to comment Share on other sites More sharing options...
math_php Posted November 29, 2015 Share Posted November 29, 2015 Hi, I think you will find everything you need in the bestseller module and in ProductSale class, it is very close to what you are actually making. Regards Link to comment Share on other sites More sharing options...
sarfaraz.r1406 Posted November 29, 2015 Author Share Posted November 29, 2015 Hi, I am taking the reference of New Product blocks module, only that I am changing the sql condition. (instead of "condition = 'new'" I am making id_products IN $array). That module is properly displaying the prices and specific prices. I am not getting the clue how that module is properly. Link to comment Share on other sites More sharing options...
chrisranjana.com Posted November 30, 2015 Share Posted November 30, 2015 ...the variable $results contain the id of all the products recently ordered by the current customer. Have you checked whether $result contains the price ? 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