Skip to content

Commit

Permalink
// [*] Made pack products available to template...
Browse files Browse the repository at this point in the history
...as usual product arrays and not a special form thereof,
also introduced minimal "pack-product-miniature.tpl" template
because the role is very different form that of the usual product-miniature
  • Loading branch information
djfm committed Feb 9, 2016
1 parent 81c6545 commit d941e66
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
16 changes: 14 additions & 2 deletions controllers/front/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,20 @@ public function initContent()
$this->assignAttributesCombinations();

// Pack management
$pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : null;
$this->context->smarty->assign('packItems', $pack_items);
$pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : [];

$assembler = new ProductAssembler($this->context);
$presenter = $this->getProductPresenter();
$presentedPackItems = [];
foreach ($pack_items as $item) {
$presentedPackItems[] = $presenter->presentForListing(
$this->getProductPresentationSettings(),
$assembler->assembleProduct($item),
$this->context->language
);
}

$this->context->smarty->assign('packItems', $presentedPackItems);
$this->context->smarty->assign('noPackPrice', $this->product->getNoPackPrice());
$this->context->smarty->assign('displayPackPrice', ($pack_items && $productPrice < $this->product->getNoPackPrice()) ? true : false);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
Expand Down
10 changes: 10 additions & 0 deletions themes/classic/templates/catalog/pack-product-miniature.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<article>
<h1 class="h5">{$product.name}</h1>
<img
src = "{$product.cover.small.url}"
alt = "{$product.cover.legend}"
data-full-size-image-url = "{$product.cover.large.url}"
>
{$product.description_short}
{$product.description}
</article>
2 changes: 1 addition & 1 deletion themes/classic/templates/catalog/product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
<h3 class="text-uppercase _bolder">{l s='Pack content'}</h3>
{foreach from=$packItems item="product_pack"}
{block name='product_miniature'}
{include file='catalog/product-miniature.tpl' product=$product_pack}
{include file='catalog/pack-product-miniature.tpl' product=$product_pack}
{/block}
{/foreach}
</section>
Expand Down

0 comments on commit d941e66

Please sign in to comment.