2016-07-30 20 views
-1

Ich möchte zufällig die Produkte, die in Producttabslider Modul erscheinen.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'); 

Ich habe versucht, shuffle() einzugeben; aber es macht zufällig nur die neuesten Produkte hinzugefügt, und nicht den gesamten Katalog. Wer hilft mir? diese

Antwort

0

Wechsel:

$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); 

Nun ist die Steuerung: erstellen Überschreibung Klassen/ProductSale.php und nach

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

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

add:

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

Überschreibung Klassen/Produkt erstellen. PHP und ändern Sie diese

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()); 
    } 

in:

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

Ich tat, was du mir gesagt hat, aber es funktioniert nicht. Sie können es in einem Tab "In saldo" und "Ich più venduti" "In saldo" -> specialProducts "Ich più venduti" -> Bestseller http://www.sexyshopwebstore.it/new_site/ – user2077311