Wprowadziłem modyfikację z forum presty en, jest to proste wyświetlenie zawartych atrybutów w produkcie dla produktów wyświetlonych z kategorii, jak poniżej:
I wszystko pracuje poprawnie, poza jednym, każde wciśniecie filtra (blocklayered) kasuje zawartość wprowadzonej modyfikacji w tpl, na debugu widać że ginie zmienna $combinations.
Siedzę juz pół dnia i nie mam już pomysłów. Jak to rozwiązać aby działało również poprawnie z filtrami?
Question
zbi
Witam,
Wprowadziłem modyfikację z forum presty en, jest to proste wyświetlenie zawartych atrybutów w produkcie dla produktów wyświetlonych z kategorii, jak poniżej:
CategoryController.php
$this->products = $this->category->getProducts($this->context->language->id, (int)$this->p, 10000, $this->orderBy, $this->orderWay); $this->combinations = $this->getProductAttributeCombinations($this->products); $this->context->smarty->assign(array( 'category' => $this->category, 'description_short' => Tools::truncateString($this->category->description, 350), 'products' => (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : null, 'id_category' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers(), 'body_classes' => array($this->php_self.'-'.$this->category->id, $this->php_self.'-'.$this->category->link_rewrite), 'combinations' => $this->combinations, )); }public function getProductAttributeCombinations($products) { $combinations = array(); foreach($products as $product) { // load product object $product = new Product ($product['id_product'], $this->context->language->id); // get the product combinations data // create array combinations with key = id_product $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id); } return $combinations; }product-list.tpl
{if isset($combinations)} <span class="product_combinations"> <strong>{l s='Formats:'}</strong> {foreach from=$combinations[$product.id_product] key=id_attribute_combination item=combination name="combination"} {if $combination|@count} <span>{$combination.attribute_name|escape:'html':'UTF-8'} - {if !$smarty.foreach.combination.last},{/if}</span><br /> {/if} {/foreach} </span> {/if}==============================
I wszystko pracuje poprawnie, poza jednym, każde wciśniecie filtra (blocklayered) kasuje zawartość wprowadzonej modyfikacji w tpl, na debugu widać że ginie zmienna $combinations.
Siedzę juz pół dnia i nie mam już pomysłów. Jak to rozwiązać aby działało również poprawnie z filtrami?
Pomóżcie.
Link to comment
Share on other sites
2 answers to this question
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