Jump to content

Merubah BestSalesQuantity di modul BlockBestSellers menjadi BestSalesAmount


Recommended Posts

Pertama, buat cadangan untuk file ProcuctSale.php on di folder classes dan blockbestsellers.php di folder module/blockbestsellers.

Rubah ProductSale.php, dengan menambahkan beberapa code sebelum karakter '} ?>' di akhir file
sebelum

}
?>


tambahkan code

   static public function getBestSalesAmount($id_lang, $pageNumber = 0, $nbProducts = 10)
   {
       global $link, $cookie;

       if ($pageNumber < 0) $pageNumber = 0;
       if ($nbProducts < 1) $nbProducts = 10;

       $result = Db::getInstance()->ExecuteS('
       SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, i.`id_image`, il.`legend`,  
           ROUND(IFNULL(SUM((od.product_price * od.product_quantity) / c.conversion_rate), 0), 2) AS sales,
           p.`ean13`, cl.`link_rewrite` AS category            
       FROM `'._DB_PREFIX_.'product_sale` ps 
       LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
       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_.'category_lang` cl ON (cl.`id_category` = p.`id_category_default` AND cl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN '._DB_PREFIX_.'order_detail od ON od.product_id = p.id_product
       LEFT JOIN '._DB_PREFIX_.'orders o ON od.id_order = o.id_order
       LEFT JOIN '._DB_PREFIX_.'currency c ON o.id_currency = c.id_currency
       WHERE p.`active` = 1
       AND 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` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
       )
       GROUP BY p.`id_product`
       ORDER BY sales DESC
       LIMIT '.intval($pageNumber * $nbProducts).', '.intval($nbProducts));

       if (!$result)
           return $result;

       foreach ($result AS &$row)
       {
            $row['link'] = $link->getProductLink($row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
            $row['id_image'] = Product::defineProductImage($row);
       }
       return $result;    
   }
}
?>



di file blockbestsellers.php, rubah pada baris 35
dari

$bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5);


menjadi

$bestsellers = ProductSale::getBestSalesAmount(intval($params['cookie']->id_lang), 0, 5);



semoga bermanfaat.

http://akbarkurniawan.web.id/2010/07/merubah-bestsalesquantity-di-modul-blockbestsellers-menjadi-bestsalesamount-pada-prestashop/

Link to comment
Share on other sites

×
×
  • Create New...