Mặc định thì module blockspecials này chỉ hiển thị 1 sản phẩm giảm giá ngẫu nhiên. Vì vậy để thêm nhiều sản phẩm khuyến mại trong gian hàng PrestaShop, bạn cần thực hiện các bước sau
Tạo thêm hàm lấy sản phẩm khuyến mại getSpecialProduct theo số lượng, thứ tự sắp xếp...
Sao lưu các file trước khi chỉnh sửa hoặc thay thế chúng.
Áp dụng cho PrestaShop 1.1
1. Bước 1
Mở file /prestashop/classes/Product.php
Tìm hàm getRandomSpecial hoặc
Nhảy đến dòng 1010 và thêm đoạn mã sau:
/**
* Get a special product
* Modified by www.kenh360.com
* @param integer $id_lang Language id
* @return array Special
*/
static public function getSpecialProduct($id_lang,$nbProducts = 5, $orderBy = NULL, $orderWay = NULL,$beginning = false, $ending = false)
{
global $link, $cookie;
if ($nbProducts < 1) $nbProducts = 5;
if (empty($orderBy)) $orderBy = 'myprice';
if (empty($orderWay)) $orderWay = 'DESC';
if ($orderBy == 'id_product' OR $orderBy == 'price' OR $orderBy == 'date_add')
$orderByPrefix = 'p';
elseif ($orderBy == 'name')
$orderByPrefix = 'pl';
if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay))
die (Tools::displayError());
$currentDate = date('Y-m-d');
$row = Db::getInstance()->getRow('
SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`,
i.`id_image`, il.`legend`, t.`rate`
FROM `'._DB_PREFIX_.'product` p
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`
WHERE (`reduction_price` > 0 OR `reduction_percent` > 0)
'.((!$beginning AND !$ending) ?
'AND (`reduction_from` = `reduction_to` OR (`reduction_from` <= \''.$currentDate.'\' AND `reduction_to` >= \''.$currentDate.'\'))'
:
($beginning ? 'AND `reduction_from` <= \''.$beginning.'\'' : '').($ending ? 'AND `reduction_to` >= \''.$ending.'\'' : '')).'
AND p.`active` = 1
ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'`'.' '.pSQL($orderWay).'
LIMIT '.intval($nbProducts));
if($orderBy == 'price')
{
Tools::orderbyPrice($result,$orderWay);
}
if ($row)
return Product::getProductProperties($id_lang, $row);
return $row;
}
2. Bước 2
Mở file /module/blockspecials/blockspecials.php
Tìm dòng 24 và thay thế hàm hookRightColumn bằng đoạn mã sau
// Modified by www.kenh360.com
function hookRightColumn($params)
{
global $smarty;
$special_products = Product::getSpecialProduct(intval($params['cookie']->id_lang), 5);
$specials = array();
if ($special_products){
foreach ($special_products AS $special)
$specials[] = $special;
$smarty->assign(array(
'specials' => $specials,
'oldPrice' => number_format($specials['price'] + $specials['reduction'], 2, '.', '')
));
}
return $this->display(__FILE__, 'blockspecials.tpl');
}
3. Bước 3
Mở file /module/blockspecials/blockspecials.tpl
<!-- MODULE Block specials -->Modified by www.kenh360.com
<!-- Modified by www.kenh360.com -->
<div id="special_block_right" class="block products_block exclusive blockspecials">
<h4><a href="/cntt/{$base_dir}prices-drop.php" title="{l s='Specials' mod='blockspecials'}">{l s='Specials' mod='blockspecials'}</a></h4>
<div class="block_content">
{if $specials}
<ul class="products">
{foreach from=$specials item=special name=myLoop}
<li class="product_image">
<a href="/cntt/{$special.link}"><img src="/cntt/{$link->getImageLink($special.link_rewrite, $special.id_image, 'medium')}" alt="{$special.legend|escape:htmlall:'UTF-8'}" title="{$special.name|escape:htmlall:'UTF-8'}" /></a>
</li>
<li>
<h5><a href="/cntt/{$special.link}" title="{$special.name|escape:htmlall:'UTF-8'}">{$special.name|escape:htmlall:'UTF-8'}</a></h5>
<span class="price-discount">{displayWtPrice p=$special.price_without_reduction}</span>
{if $special.reduction_percent}<span class="reduction">(-{$special.reduction_percent}%)</span>{/if}
<span class="price">{displayWtPrice p=$special.price}</span>
</li>
{/foreach}
</ul>
<p>
<a href="/cntt/{$base_dir}prices-drop.php" title="{l s='All specials' mod='blockspecials'}" class="button">{l s='All specials' mod='blockspecials'}</a>
</p>
{else}
<p>{l s='No specials at this time' mod='blockspecials'}</p>
{/if}
</div>
</div>
<!-- /MODULE Block specials -->
| Prestashop Module - Bản đồ Google MAP < Lùi | Tiếp theo > Tạo module Sản phẩm nổi bật cho PrestaShop |
|---|
Tin mới hơn:
- 08/11/2010 10:41 - Hướng dẫn tích hợp Ngân Lượng vào PrestaShop
Tin cũ hơn:
- 27/05/2009 09:41 - PrestaShop Module điều hướng - Blocknavigation
- 08/05/2009 00:02 - Lựa chọn hình ảnh logo hoặc flash giới thiệu sản phẩm trong PrestaShop Module editorial
- 07/05/2009 23:58 - PrestaShop Module - Yêu cầu thông tin sản phẩm
- 07/05/2009 23:51 - Prestashop Module - Bản đồ Google MAP
- 07/05/2009 23:47 - Hiển thị Sản phẩm ngẫu nhiên trong Prestashop
Download Game bóng đá PES8 Việt Nam
Tải game bóng đá FiFa 09
Tải game Dragon ball Z - 7 viên ngọc rồng
Tải Game Bóng Đá Pro Evolution Soccer 6 Việt Nam
Download PES 2011 patch Việt Nam PESVN
Tải Game Bóng Đá FIFA 2009 RIP 1 CD
Download Pro Evolution Soccer 2011
Download Game THE SIMS 3
Tải Game bóng đá PES 2009
Download PES 2011 demo
Thay đổi màn hình đăng nhập Windows 7 bằng tay
Một số hàm hay dùng trong JavaScript
Kiểm soát hoàn toàn trỏ chuột bằng bàn phím với NeatMouse
Choáng với concept của Windows Phone 8
Những đặc điểm ưu việt của Windows Phone
Ứng dụng gọi điện VoIP Viber sắp có mặt trên Windows Phone
Game Diablo 3 sắp có mặt trên Windows Phone Marketplace
37 trang css & xhtml web template miễn phí tuyệt đẹp
Những điều cơ bản cần biết về bàn phím chơi game - Gaming Keyboard
L.A. Noire: The Complete Edition - THETA [Full ISO/Action/2011] [13.37GB]
Download 7554 demo
Download Game PC, cập nhật liên tục (torrent)
PES 2012 ra mắt bản mở rộng đầu tiên vào 11/10
PES2012 - Full version - Ngôn ngữ và bình luận tiếng Anh
PES2012 - Blurry disable làm mịn đồ họa
PES 2011 PATCH 4.1 - TRANSFER UPDATE - RELEASED
Bộ sưu tập free PrestaShop Themes phần 3
Bộ sưu tập theme Prestashop miễn phí phần 2
Top 10 Free PrestaShop Themes
Download Prestashop 1.5
Download PrestaShop 1.4
Bổ sung Memcached vào PrestaShop 1.4
Hướng dẫn tích hợp Ngân Lượng vào PrestaShop
Sửa lỗi invalid carrier or no carrier selected trong PrestaShop
Cài đặt PrestaShop
Thiết kế giao diện PrestaShop Theme
Hướng dẫn cài đặt themes trong PrestaShop
Hướng dẫn cách thêm ngôn ngữ cho PrestaShop
Bộ sưu tập Giao diện Premium PrestaShop Themes chuyên nghiệp
Giới thiệu về website thương mại điện tử 2.0 Prestashop
Máy tính 3,8 triệu đồng kèm màn hình LCD 16 inch
Vẻ đẹp Gợi cảm tự nhiên
Tính năng mới của Mozilla Firefox 3.0.10
Tuyển lọc các Game nhỏ mà hay P2


