From d941e66e9cb7cf5dc3f0e8fddf04cd45a262b51c Mon Sep 17 00:00:00 2001 From: djfm Date: Tue, 9 Feb 2016 17:22:40 +0100 Subject: [PATCH] // [*] Made pack products available to template... ...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 --- controllers/front/ProductController.php | 16 ++++++++++++++-- .../templates/catalog/pack-product-miniature.tpl | 10 ++++++++++ themes/classic/templates/catalog/product.tpl | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 themes/classic/templates/catalog/pack-product-miniature.tpl diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a146a7c912981..a21ddf4b7348f 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -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)); diff --git a/themes/classic/templates/catalog/pack-product-miniature.tpl b/themes/classic/templates/catalog/pack-product-miniature.tpl new file mode 100644 index 0000000000000..a1a330ef05c16 --- /dev/null +++ b/themes/classic/templates/catalog/pack-product-miniature.tpl @@ -0,0 +1,10 @@ +
+

{$product.name}

+ {$product.cover.legend} + {$product.description_short} + {$product.description} +
diff --git a/themes/classic/templates/catalog/product.tpl b/themes/classic/templates/catalog/product.tpl index 82737e3e6513c..d331cf0dd039d 100644 --- a/themes/classic/templates/catalog/product.tpl +++ b/themes/classic/templates/catalog/product.tpl @@ -351,7 +351,7 @@

{l s='Pack content'}

{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}