https://medium.com/@lmeyer./get-an-error-free-e-commerce-web-site-using-sentry-b6061264efc8...
Prestashop page Catégorie - Mettre les produits sans images en derniers
<?php
/**
* 2007-2022 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2022 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class cafe_catmultiorder extends Module
{
public function __construct()
{
$this->name = 'cafe_catmultiorder';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'presta.cafe';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('cafe_catmultiorder');
$this->description = $this->l('Allow you to manage category multiple sort in productlist');
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
}
public function install()
{
return parent::install() &&
$this->registerHook('actionProductSearchProviderRunQueryAfter');
}
public function uninstall()
{
return parent::uninstall();
}
public function hookActionProductSearchProviderRunQueryAfter(array $params)
{
$products = $params["result"]->getProducts();
$products_with_imgs = [];
$products_no_imgs = [];
foreach ($products as $product) {
$cover = Product::getCover($product["id_product"]);
if ($cover) {
//filtre produit avec images
$products_with_imgs[] = ['id_product' => $product["id_product"]];
} else {
//filtre produit sans images
$products_no_imgs[] = ['id_product' => $product["id_product"]];
}
}
// on merge les deux array l'un apres l'autre
$new_product = array_merge($products_with_imgs, $products_no_imgs);
$params["result"]->setProducts($new_product);
}
}
Publié dans:
Aide Prestashop
Laissez un commentaire