如何修改PrestaShop显示特价产品的数量?
其实,我很早就想修改PrestaShop网站前台显示的特价产品数量,因为,我再怎么调整页面只显示一个特价产品。相信很多做英文外贸SEO的朋友也会遇到这个问题,或许,你也想修改Prestashop网站显示的特价产品的数量。不过,这个特价产品显示的数量修改的工作量还是比较大的,我在网上找了很久才到一个prestashop论坛里面找到如何修改prestashop网站显示的特价产品数量,现在和大家一起分享一下:
把/classes/Product.php的getRandomSpecial方法(第1158行)修改为如下:
view plaincopy to clipboardprint?
static public function getRandomSpecial($id_lang, $beginning = false, $ending = false, $limit = 1)
{
global $link, $cookie;
$currentDate = date('Y-m-d H:m:i');
$sql = '
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` <= \''.pSQL($currentDate).'\' AND `reduction_to` >= \''.pSQL($currentDate).'\'))'
:
($beginning ? 'AND `reduction_from` <= \''.pSQL($beginning).'\'' : '').($ending ? 'AND `reduction_to` >= \''.pSQL($ending).'\'' : '')).'
AND 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).')').'
)
ORDER BY RAND()
LIMIT '.$limit;
$results = Db::getInstance()->ExecuteS($sql);
if ($results)
{
$newresults = array();
foreach($results as $row)
$newresults[] = Product::getProductProperties($id_lang, $row);
return $newresults;
}
return $results;
}
将/modules/blockspecials/blockspecials.php的30行改为:
view plaincopy to clipboardprint?
if ($specials = Product::getRandomSpecial(intval($params['cookie']->id_lang), false, false, 5))
32行改为:
'specials' => $specials,
/modules/blockspecials/blockspecials.tpl第5-16行替换为:
view plaincopy to clipboardprint?
{if $specials}
{foreach from=$specials item=special}
<div style="display:block;float:left;">
<ul class="products">
<li class="product_image">
<a href="{$special.link}"><img src="http://chineseb2c.com/{$lin title=" 如何修改prestashop显示特价产品的数量?"="" alt="">getImageLink($special.link_rewrite, $special.id_image, 'medium')}" alt="{$special.legend|escape:html:'UTF-8'}" height="{$mediumSize.height}" width="{$mediumSize.width}" title="{$special.name|escape:html:'UTF-8'}" /></a>
</li>
<li>
<h5><a href="{$special.link}" title="{$special.name|escape:html:'UTF-8'}">{$special.name|escape:html:'UTF-8'}</a></h5>
<span class="price-discount">{if !$priceDisplay}{displayWtPrice p=$special.price_without_reduction}{else}{displayWtPrice p=$priceWithoutReduction_tax_excl}{/if}</span>
{if $special.reduction_percent}<span class="reduction">(-{$special.reduction_percent}%)</span>{/if}
<span class="price">{if !$priceDisplay}{displayWtPrice p=$special.price}{else}{displayWtPrice p=$special.price_tax_exc}{/if}</span>
</li>
</ul>
</div>
{/foreach}
欢迎更多外贸英文SEO的朋友一起交流PrestaShop应用的心得,大家在操作PrestaShop SEO方面遇到哪些问题可以一起交流!
评论 (0)