public function hookDisplayHome($params)
{
$lang_id = (int) Configuration::get('PS_LANG_DEFAULT');
// récupération de l'id Produit depuis le BO
$id_product = Configuration::get('MYMODULE_CONFIG');
// récupération produit
$product = new Product($id_product, true, $lang_id);
// prix TTC
$price = $product->getPricesDrop($id_product);
// $flags = discount::get();
// Hook displayProductExtraContent
// $extraContentFinder = new ProductExtraContentFinder();
// image de couverture
$image = Product::getCover($id_product);
$cover_url = $this->context->link->getImageLink($product->link_rewrite, $image['id_image'], ImageType::getFormatedName('large'));
$other_img = $product->getImages($id_product);
$product_img = [];
foreach ($other_img as $img) {
array_push($product_img, $this->context->link->getImageLink($product->link_rewrite, $img['id_image'], ImageType::getFormatedName('large')));
}
$features = $product->getFrontFeatures($lang_id);
$attachments = Attachment::getAttachments($lang_id, $id_product);
if (Validate::isLoadedObject($product)) {
$this->context->smarty->assign([
'my_module_name' => Configuration::get('MYMODULE_NAME'),
'product' => $product,
'cover_url' => $cover_url,
'product_img' => $product_img,
'features' => $features,
'attachments' => $attachments,
'price' => $price,
]);
}
return $this->display(__FILE__, 'mymodule.tpl');
}
partie monmodule.php au dessus, ou j'ai du "trafiqué" pour récupérer certaines données, comme le prix TTC que je récupère dans getPricesDrop,
et la partie product-prices.tpl
avec en commentaire les parties que je ne peux ajouter car je n'arrive pas a récupérer des variables, ou que je dois recréer au sein du module car elles nécessitent des -> au lieu de . dans le code.
{if $product->show_price} <div class="product-prices js-product-prices"> {block name='product_discount'} {if $product->specificPrice} <div class="product-discount"> {hook h='displayProductPriceBlock' product=$product type="old_price"} <span class="regular-price">{$price.0.price_without_reduction}€</span> </div> {/if} {/block} {block name='product_price'} <div class="product-price h5 {if $product->specificPrice}has-discount{/if}"> <div class="current-price"> <span class='current-price-value' content="{$product->price}"> {capture name='custom_price'}{hook h='displayProductPriceBlock' product=$product type='custom_price' hook_origin='product_sheet'}{/capture} {if '' !== $smarty.capture.custom_price} {$smarty.capture.custom_price nofilter} {else} {$price.0.price}€ {/if} </span> {if $product->specificPrice} {if $product->specificPrice.reduction_type === 'percentage'} <span class="discount discount-percentage">{l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => ($product->specificPrice.reduction * 100)]}% </span> {else} <span class="discount discount-amount"> {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $price.0.reduction]}€ </span> {/if} {/if} </div> {* {block name='product_unit_price'} {if $product->unit_price} <p class="product-unit-price sub">{l s='(%unit_price%)' d='Shop.Theme.Catalog' sprintf=['%unit_price%' => $product->unit_price]}</p> {/if} {/block} *} </div> {/block} {* {block name='product_without_taxes'} {if $priceDisplay == 2} <p class="product-without-taxes">{l s='%price% tax excl.' d='Shop.Theme.Catalog' sprintf=['%price%' => $product.price_tax_exc]}</p> {/if} {/block} *} {* {block name='product_pack_price'} {if $displayPackPrice} <p class="product-pack-price"><span>{l s='Instead of %price%' d='Shop.Theme.Catalog' sprintf=['%price%' => $noPackPrice]}</span></p> {/if} {/block} *} {block name='product_ecotax'} {if $product->ecotax > 0} <p class="price-ecotax">{l s='Including %amount% for ecotax' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product->ecotax]} {if $product->specificPrice} {l s='(not impacted by the discount)' d='Shop.Theme.Catalog'} {/if} </p> {/if} {/block} {hook h='displayProductPriceBlock' product=$product type="weight" hook_origin='product_sheet'} <div class="tax-shipping-delivery-label"> {* {if !$configuration.taxes_enabled} {l s='No tax' d='Shop.Theme.Catalog'} {elseif $configuration.display_taxes_label} {$product.labels.tax_long} {/if} *} {hook h='displayProductPriceBlock' product=$product type="price"} {hook h='displayProductPriceBlock' product=$product type="after_price"} {if $product->is_virtual == 0} {* {if $product->additional_delivery_times == 1} {if $product.delivery_information} <span class="delivery-information">{$product.delivery_information}</span> {/if} {elseif $product->additional_delivery_times == 2} *} {if $product->quantity > 0} <span class="delivery-information">{$product->delivery_in_stock}</span> {* Out of stock message should not be displayed if customer can't order the product. *} {elseif $product->quantity <= 0 } <span class="delivery-information">{$product->delivery_out_stock}</span> {/if} {* {/if} *} {/if} </div> </div> {/if}