2016-07-30 3 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'); 

나는 shuffle(); 그러나 전체 카탈로그가 아닌 최신 제품 만 무작위로 추가합니다. 누가 나를 도와 줍니까?

답변

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

난 당신이 나에게 말한했지만 작동하지 않습니다. "Saldo"및 "I salu"탭에서 볼 수 있습니다 - "specialto"제품 - "베스트셀러"-> 베스트셀러 http://www.sexyshopwebstore.it/new_site/ – user2077311