zack24 Posted May 17, 2024 Share Posted May 17, 2024 Bonjour à tous, je souhaite rafraichir à chaque chengement de déclinaison la donnée d'un champ personnalisé "pack" entier (int) crée dans les tables ps_stock_available et ps_product. je veux qu'il soit rafraichi tout comme le prix mais seulement je n'ai aucune idée comment mettre celà en place. je vous joint l'override de mon fichier productController; j'accede à cette valeur depuis la page product.tpl par le script suivant : <span id="product-pack" data-pack="{$pack}">{$pack}</span> mon fichier productController.php : <?php use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray; use PrestaShop\PrestaShop\Core\Product\ProductExtraContentFinder; use Product; use Tools; use Validate; use Category; use Hook; use Combination; use Context; use Group; use Tax; use ImageManager; use Manufacturer; use Db; class ProductController extends ProductControllerCore { public function initContent() { parent::initContent(); $productId = (int)Tools::getValue('id_product'); $productAttributeId = (int)Tools::getValue('id_product_attribute'); $sqlStockAvailable = 'SELECT pack FROM ' . _DB_PREFIX_ . 'stock_available WHERE id_product = ' . $productId . ' AND id_product_attribute = ' . $productAttributeId; $packValue = Db::getInstance()->getValue($sqlStockAvailable); if ($packValue === false || $packValue == 0) { $sqlProduct = 'SELECT pack FROM ' . _DB_PREFIX_ . 'product WHERE id_product = ' . $productId; $packValue = Db::getInstance()->getValue($sqlProduct); } if ($packValue === false) { $packValue = 'N/A'; // Valeur par défaut si aucune donnée n'est trouvée } $this->context->smarty->assign('pack', $packValue); } } d'avance merci pour votre aide. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now