2016-07-30 9 views
-1

producttabsliderモジュールに表示される製品をランダムに使用したいと思います。SlideTabProduct prestashop

public function hookblockPosition3($params) { 
     $nb = Configuration::get($this->name . '_p_limit'); 
     $newProducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5)); 
     $specialProducts = Product::getPricesDrop((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5),false,'date_add', 'DESC'); 
     shuffle($specialProducts); 
     ProductSale::fillProductSales(); 
     $bestseller = $this->getBestSales ((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5), null, null); 
     shuffle($bestseller); 
     $category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); 
     shuffle($category); 
     $featureProduct = $category->getProducts((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5),'date_add', 'DESC'); 

私はシャッフル()を入力しようとしました。それはカタログ全体ではなく最新の製品だけをランダムに作成します。 誰が助けてくれますか?

答えて

0

変更この:今

$nb = Configuration::get($this->name . '_p_limit'); 
$newProducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5),false,'rand'); 
$specialProducts = Product::getPricesDrop((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5),false,'date_add', 'DESC'); 
ProductSale::fillProductSales(); 
$bestseller = $this->getBestSales ((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5), 'rand', null); 
$category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id); 
$featureProduct = $category->getProducts((int) Context::getContext()->language->id, 0, ($nb ? $nb : 5),'date_add', 'DESC',false,true,true); 

コントローラ: オーバーライドクラス/ ProductSale.phpを作成し、

if ($order_by == 'date_add' || $order_by == 'date_upd') { 
     $order_table = 'product_shop'; 
    } 

    if (is_null($order_way) || $order_by == 'sales') { 
     $order_way = 'DESC'; 
    } 

追加した後:

if ($order_by == 'rand'){ 
    $order_by = 'RAND()'; 
    $order_way = ''; 
} 

オーバーライドクラス/製品を作成します。 PHPを修正して

if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') { 
     $order_by_prefix = 'product_shop'; 
    } elseif ($order_by == 'name') { 
     $order_by_prefix = 'pl'; 
    } 
    if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) { 
     die(Tools::displayError()); 
    } 

if ($order_by == 'id_product' || $order_by == 'price' || $order_by == 'date_add' || $order_by == 'date_upd') { 
     $order_by_prefix = 'product_shop'; 
    } elseif ($order_by == 'name') { 
     $order_by_prefix = 'pl'; 
    } 
    if ((!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) && $order_by != 'rand') { 
     die(Tools::displayError()); 
    }elseif ($order_by == 'rand') { 
     $order_by = 'RAND()'; 
     $order_way = '';    
    } 
+0

私はあなたが私に言った何をしたが、それは動作しません。あなたは "サルド"と "私はサルード"のタブでそれを見ることができます - > specialProducts "私は仲間" - >ベストセラー http://www.sexyshopwebstore.it/new_site/ – user2077311