SlideTabProduct prestashop

SlideTabProduct prestashop,prestashop,Prestashop,我想随机选择producttabslider模块中出现的产品 public function hookblockPosition3($params) { $nb = Configuration::get($this->name . '_p_limit'); $newProducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, ($nb ? $nb

我想随机选择producttabslider模块中出现的产品

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');
我试图进入洗牌();但它只随机添加最新的产品,而不是整个目录。 谁帮助我?

更改此选项:

$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';
    }
加:

创建覆盖类/Product.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());
    }
在:


我照你说的做了,但没用。您可以在标签“在saldo”和“在saldo”中的“I piùvenduti”->特殊产品“I piùvenduti”->畅销书中查看它
    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 = '';            
    }