4natic Posted April 3, 2012 Report Share Posted April 3, 2012 Никак не получается вывести свойства к каждому товару на странице категории.Simpla 2.1 Буду очень благодарен за помощь. Всем заранее спасибо. Quote Link to post Share on other sites
4natic Posted April 5, 2012 Author Report Share Posted April 5, 2012 Ни у кого нет идей, как это можно сделать? Quote Link to post Share on other sites
Kpoxa Posted April 5, 2012 Report Share Posted April 5, 2012 Приведите пример, скриншоты что и где Вы хотели бы видеть и что Вы для этого делали. Quote Link to post Share on other sites
Mariik Posted April 5, 2012 Report Share Posted April 5, 2012 Что значит "свойства к каждому товару" ? Может Вы говорите о свойствах категории товаров? Quote Link to post Share on other sites
4natic Posted April 5, 2012 Author Report Share Posted April 5, 2012 Ну всем товарам можно задавать свойства, например "вес", "размер" и т.д. По этим же свойствам можно сортировать товары в категории.За вывод свойств на странице товара отвечает такой код в файле ProductView.php:$product->features = $this->features->get_product_options(array('product_id'=>$product->id));и такой код в шаблоне:{foreach $product->features as $f} <li> <label>{$f->name}</label> <span>{$f->value}</span> </li> {/foreach}Пытался по аналогии с картинками и вариантами добавить такой код в ProductView.php: foreach($products as &$product) { $product->variants = array(); $product->images = array(); $product->properties = array(); } $variants = $this->variants->get_variants(array('product_id'=>$products_ids, 'instock'=>true)); foreach($variants as &$variant) { //$variant->price *= (100-$discount)/100; $products[$variant->product_id]->variants[] = $variant; } $images = $this->products->get_images(array('product_id'=>$products_ids)); foreach($images as $image) $products[$image->product_id]->images[] = $image; $properties = $this->features->get_product_options(array('product_id'=>$products_ids)); foreach($properties as &$property){ $products[$property->product_id]->properties[] = $property; } foreach($products as &$product) { if(isset($product->variants[0])) $product->variant = $product->variants[0]; if(isset($product->images[0])) $product->image = $product->images[0]; if(isset($product->properties[0])) $product->property = $product->properties[0]; }и так вызвать его в шаблоне products.tpl:<table style="padding: 5px;"> {foreach from=$product->properties item=property} <tr><td><b>{$property->name|escape}</b></td><td>{$property->value|escape}</td></tr> {/foreach}</table>Но это не привело к нужному результату. Quote Link to post Share on other sites
Kpoxa Posted April 5, 2012 Report Share Posted April 5, 2012 а не пробовали скопировать код вывода свойств из product.tpl? Quote Link to post Share on other sites
4natic Posted April 5, 2012 Author Report Share Posted April 5, 2012 Ну я так, в принципе, и сделал. Но это не работает. Quote Link to post Share on other sites
SergeyKH Posted April 6, 2012 Report Share Posted April 6, 2012 http://forum.simplacms.ru/discussion/1203/kak-vyvodit-svoystva-tovara-v-bloke-tovara-v-kategoriyah-v-prodakts-tpl#Item_4По-моему уже нашли решение тут Quote Link to post Share on other sites
4natic Posted April 6, 2012 Author Report Share Posted April 6, 2012 Спасибо большое - это то, что нужно. Quote Link to post Share on other sites
ApacHee Posted March 18, 2014 Report Share Posted March 18, 2014 http://forum.simplacms.ru/discussion/1203/kak-vyvodit-svoystva-tovara-v-bloke-tovara-v-kategoriyah-v-prodakts-tpl#Item_4По-моему уже нашли решение тутбитая ссылка Quote Link to post Share on other sites
manchi Posted March 24, 2014 Report Share Posted March 24, 2014 будьте добры, воскресите ссылку Quote Link to post Share on other sites
Vanger Posted April 11, 2014 Report Share Posted April 11, 2014 вывод характеристик (свойств) товаров на страницах категорий в шаблоне products.tpl в цикле вывода товаров пишем: <ul class="features"> {foreach $product->options as $po} <li> <label>{$po->name}</label> <span>{$po->value}</span> </li> {/foreach} </ul> В файле view/ProductsView.php после: foreach($products as &$product) { if(isset($product->variants[0])) $product->variant = $product->variants[0]; if(isset($product->images[0])) $product->image = $product->images[0]; }добавим следующий код: $properties = $this->features->get_product_options($products_ids); foreach($properties as $property) { $products[$property->product_id]->options[] = $property; }Готово! Quote Link to post Share on other sites
Flexux Posted September 21, 2014 Report Share Posted September 21, 2014 а когда хотел сделать на главной вывод характеристик в новинках не сработало . Quote Link to post Share on other sites
SiteDream Posted March 14, 2016 Report Share Posted March 14, 2016 А как вывести только 1 свойство? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.