Reputation: 13333
In Prestashop I want to display all of the data of the products just like the product loop page. For that I have an array of products id. The code s like this
$id_lang=Configuration::get('PS_LANG_DEFAULT');
$id_products = array(2,3,4,6,7);
$all_products = array();
foreach ($id_products as $id_product ) {
$product_id = $id_product;
$link = new Link();
$image = Image::getCover($product_id);
$url = $link->getProductLink($product_id);
$product = new Product($product_id);
$imagePath = Link::getImageLink($product->link_rewrite, $image['id_image'], 'home_default');
array_push($all_products, $product);
}
$this->context->smarty->assign(
array(
'all_products' => $all_products,
'lang_id' => $id_lang,
'url' => $url,
)
);
and in the smarty I have done my code like this
<ul>
<!-- {$all_products|@print_r} -->
{foreach from=$all_products item=product name=product}
<li class="col-xs-12 col-sm-4 col-md-3 first-in-line">
<div class="product-container" itemscope itemtype="http://schema.org/Product">
<div class="left-block">
<div class="product-image-container">
<a class="product_img_link" href="{$url}" title="{$product->name|escape:'html':'UTF-8'}" itemprop="url">
<img class="replace-2x img-responsive" src="" >
</a>
</div>
</div>
</div>
{/foreach}
</ul>
Here in the smarty I have done copy and paste product-list.tpl
files code as I want my custom loop should look exactly like that but it is showing many errors. So can someone kindly tell me how can I get the exactly look of the product list page with products id? Any help and suggestions will be really appreciable. Thanks
Upvotes: 0
Views: 306