Перейти к содержанию
Официальный форум поддержки Simpla

Помогите вывести свойства товаров в каталоге товаров


Рекомендуемые сообщения

Прошу помочь с выводом свойств в каталог.

вообщем есть сайт на симпле, изначально выводился товар в 4 колонки, нужно было чтобы в 1 колонку, с этим я справился. Дальше нужно сделать чтобы справа от картинки товара выводились свойства этого товара, абсолютно так же само как они выводятся если зайти непосредственно в карточку товара.
я нашел строку которая отвечает за вывод свойств :
{if $product->features}

        <div id="features">
        <ul>
        {foreach $product->features as $f}
        <li><p class="name">{$f->name}:</p><p class="values">{$f->value}</p></li>
        {/foreach}
        <ul>
    </div>
{/if}

 

прикрутил ее к tpl_products_blocks после вывода картинки, но ничего не происходит!
покапавшись в php страницах сайта, я нашел в файле product_view такие строчки:

// Свойства товаров
        if(!empty($category))
        {
            $features = array();
            foreach($this->features->get_features(array('category_id'=>$category->id, 'in_filter'=>1)) as $feature)
            
                $features[$feature->id] = $feature;
                if(($val = strval($this->request->get($feature->id)))!='')
                    $filter['features'][$feature->id] = $val;    
            }
            $options_filter['visible'] = 1;            
            $features_ids = array_keys($features);
            if(!empty($features_ids))
                $options_filter['feature_id'] = $features_ids;
            $options_filter['category_id'] = $category->children;
            if(isset($filter['features']))
                $options_filter['features'] = $filter['features'];
            if(!empty($brand))
                $options_filter['brand_id'] = $brand->id;            
            $options = $this->features->get_options($options_filter);
            foreach($options as $option)
            {
                if(isset($features[$option->feature_id]))
                    $features[$option->feature_id]->options[] = $option;
            }            
            foreach($features as $i=>&$feature)
            
                if(empty($feature->options))
                    unset($features[$i]);
            }
            $this->design->assign('features', $features);
         }
 
Как я понимаю они отвечают за объявление переменных для свойств товаров, дальше как я понял их нужно вставить в еще какойто файл, которые отвечает за каталог товаров
но вот в какой именно файл, мне не удалось понять, мучаюсь уже какой день и никак не могу найти решение...
Кто нибудь, подскажите пожалуйста как это сделать, очень нужно
Ссылка на сообщение
Поделиться на другие сайты
 

покажите весь код вашего products.tpl

 
Вот, весь код, только вывод свойств я находил не в products.tpl, а в product.tpl
<div id="page_title">
    <p><a href="./">Главная</a>
    {if $category}
        {foreach from=$category->path item=cat} » <a class='link_2' href="catalog/{$cat->url}">{$cat->name|escape}</a>{/foreach}
        {if $brand}» <a class='link_2' href="catalog/{$cat->url}/{$brand->url}">{$brand->name|escape}</a>{/if}
    {elseif $brand}» <a class='link_2' href="brands/{$brand->url}">{$brand->name|escape}</a>
    {elseif $keyword}» Поиск
    {/if}
    </p>    
    <h1>
    {if $keyword}Поиск {$keyword|escape}
    {elseif $page}{$page->name|escape}
    {else}{$category->name|escape} {$brand->name|escape} {$keyword|escape}
    {/if}
    </h1>    
</div>
 
{if $current_page_num==1 && $category->description}<div id="category_description">{if $page->body}<p>{$page->body}</p>{/if}{$category->description}</div>{/if}
{if $brand->description && $current_page_num==1}<div id="category_description"><h2>{$brand->name}</h2>{$brand->description}</div>{/if}
{if $features || $category->brands}
    <div id="features">
    <ul>
    {if $category->brands}
        <li>
        <p class="name">Бренды</p>
        <p class="values">
        <a href="catalog/{$category->url}" class='hover_mouse{if !$brand->id} selected{/if}'>Все</a>
        {foreach name=brands item=b from=$category->brands}
        <a href="catalog/{$category->url}/{$b->url}" class='hover_mouse{if $b->id == $brand->id} selected{/if}' data-brand="{$b->id}">{$b->name|escape}</a>
        {/foreach}
        </p>
        </li>
    {/if}
 
    {if $features}
        {foreach $features as $f}
        <li>
        <p class="name" data-feature="{$f->id}">{$f->name}:</p>
        <p class="values">
        <a href="{url params=[$f->id=>null, page=>null]}" class='hover_mouse{if !$smarty.get.$f@key} selected{/if}'>Все</a>
        {foreach $f->options as $o}<a href="{url params=[$f->id=>$o->value, page=>null]}" class='hover_mouse{if $smarty.get.$f@key == $o->value} selected{/if}'>{$o->value|escape}</a>{/foreach}
        </p>
        </li>
        {/foreach}
    {/if}
    </ul>
    </div>
{/if}
 
{if $products}
    {include file='pagination.tpl'}
    <ul class="tiny_products">
    {foreach $products as $product}
    <li class="product">{include file='tpl_products_blocks.tpl'}</li>
      {/foreach}
    
        
        Просмотров: {$product->views}
    </ul>
    {include file='pagination.tpl'}
{else}<h4 style='padding:50px 0;'>Сейчас здесь нет предложений<br />Попробуйте зайти позже</h4>{/if}
 
{literal}
<script>
$(function() {
    // Раскраска строк характеристик
    $("#features li:even").addClass('even');
    // Выбор вариантов
    $('select[name=variant]').change(function() {
        price = $(this).find('option:selected').attr('price');
        compare_price = '';
        if(typeof $(this).find('option:selected').attr('compare_price') == 'string')
            compare_price = $(this).find('option:selected').attr('compare_price');
        $(this).find('option:selected').attr('compare_price');
        $(this).closest('form').find('span').html(price);
        $(this).closest('form').find('strike').html(compare_price);
        return false;
    });
});
</script>
{/literal}
Ссылка на сообщение
Поделиться на другие сайты

покажите весь код вашего products.tpl

Вот, на всякий случай еще и код product.tpl

 

{$name_title = "{$product->name|escape} - Комментарии"}

<div id="page_title">
    <p>
    <a href="./">Главная</a>
    {foreach from=$category->path item=cat}» <a class='link_2' href="catalog/{$cat->url}">{$cat->name|escape}</a>{/foreach}
    {if $brand}» <a class='link_2' href="catalog/{$cat->url}/{$brand->url}">{$brand->name|escape}</a>{/if}
    </p>
    <h1 data-product="{$product->id}">{$product->name|escape}</h1>
</div>
 
<div class="product page">    
    {if $product->featured}<div class="label label_featured" title='Рекомендуемый товар (Лидер продаж)'></div>
    {elseif $product->variant->compare_price > 0}<div class="label label_sale" title='Предложение со скидкой'></div>{/if}
 
    <div class="image">
    <a href="{$product->image->filename|resize:800:600:w}" class="zoom" data-rel="group"><img src="{if $product->image}{$product->image->filename|resize:220:220}{else}design/{$settings->theme}/images/bg/nofoto.png{/if}" alt="{$product->product->name|escape}" /></a>
    </div>
 
    <div class="product_info">
 
        {if $product->images|count>1}
        {foreach $product->images|cut as $i=>$image} 
        <div class="images"><a href="{$image->filename|resize:8000:6000:w}" class="zoom" data-rel="group"><img class='hover_mouse' src="{$image->filename|resize:50:50}" alt="{$product->name|escape}" /></a></div>    
        {/foreach}        
        <div class="clear"></div>    
        {/if}
 
        {if $product->variants|count > 0}
            <form class="cart" action="/cart">
                <div class="price">
                <strike class='compare_price'>{if $product->variant->compare_price > 0}{$product->variant->compare_price|convert}{else}{/if}</strike>
                {if $product->variant->price >0}<span class='color'>{$product->variant->price|convert}</span><i class='color'>{$currency->sign|escape}</i>{else}<i style='margin:0;font-size:19px;' title='Не назначена цена'>Под заказ</i>{/if}
                </div>
Просмотров:{$product->views}
                <select name="variant" {if $product->variants|count==1  && !$product->variant->name}style='display:none;'{/if}>
                {foreach $product->variants as $v}
                {if $v->price > 0}<option value="{$v->id}" {if $v->compare_price > 0}compare_price="{$v->compare_price|convert}"{/if} price="{$v->price|convert}">{$v->name}</option>{/if}
                {/foreach}
                </select>
 
                {if $product->variant->price >0}<input type="submit" class="but_add to_cart" value="" data-result-text=""/>{/if}
            </form>
        {else}
        <div class="price"><i style='margin:0;' title='Нет на складе'><br />Нет в наличии</i></div>
        {/if}
    </div>
    <div class="share42init"></div>
    <div class="clear"></div>    
    {if $product->body}<div id="page_title"><h1>{$product->name|escape} - Информация</h1></div><div id="category_description">{$product->body}</div>{/if}
    {if $product->features}
        <div id="page_title"><h1>{$product->name|escape} - Характеристики</h1></div>
        <div id="features">
        <ul>
        {foreach $product->features as $f}
        <li><p class="name">{$f->name}:</p><p class="values">{$f->value}</p></li>
        {/foreach}
        <ul>
        </div>
    {/if}
</div>
 
<div id="back_forward">
{if $prev_product}<a class="prev_page_link hover_mouse link_2" href="products/{$prev_product->url}">{$prev_product->name|escape}</a>{/if}
{if $next_product}<a class="next_page_link hover_mouse link_2" href="products/{$next_product->url}">{$next_product->name|escape}</a>{/if}
</div>
 
{if $related_products}
    <div id="page_title"><h1>С {$product->name|escape} также смотрят</h1></div>
    <ul class="tiny_products main">
    {foreach $related_products as $product}
    <li class="product">{include file='tpl_products_blocks.tpl'}</li>
    {/foreach}
    </ul>
{/if}
<br />
{include file='tpl_comments.tpl'}
 
{literal}
<script>
$(function() {
    $("#features li:even").addClass('even');
 
    $("a.zoom").fancybox({ 'hideOnContentClick' : true });
 
    $('select[name=variant]').change(function() {
        price = $(this).find('option:selected').attr('price');
        compare_price = '';
        if(typeof $(this).find('option:selected').attr('compare_price') == 'string')
            compare_price = $(this).find('option:selected').attr('compare_price');
        $(this).find('option:selected').attr('compare_price');
        $(this).closest('form').find('span').html(price);
        $(this).closest('form').find('strike').html(compare_price);
        return false;
    });
});
</script>
{/literal}
Ссылка на сообщение
Поделиться на другие сайты

ну у вас же сам продукт в tpl_products_blocks.tpl  дайте его ))

)))Вот он

 

 

{if $product->featured}<div class="label label_featured" title='Рекомендуемый товар (Лидер продаж)'></div>
{elseif $product->variant->compare_price > 0}    <div class="label label_sale" title='Предложение со скидкой'></div>
{/if}
 
<div class="product_info">
 
    <h3><a data-product="{$product->id}" href="products/{$product->url}">{$product->name|escape}</a></h3>
        {if $product->variants|count > 0}
              <div class="image">
<a href="products/{$product->url}" title='Просмотреть предложение {$product->name|escape}'>
<img src="{if $product->image}{$product->image->filename|resize:220:220}{else}design/
 {$settings->theme}/images/bg/nofoto.png{/if}" alt="{$product->name|escape}"/></a>
{if $product->annotation}<div class="annotation">{$product->annotation}</div>{/if}
 
</div>      
{if $product->features}
        <div id="features">
        <ul>
        {foreach $product->features as $f}
        <li><p class="name">{$f->name}:</p><p class="values">{$f->value}</p></li>
        {/foreach}
        <ul>
    </div>
{/if}
            <form class="cart" action="/cart">
                        <div class="price">
            <strike class='compare_price left'>{if $product->variant->compare_price > 0}{$product->variant->compare_price|convert}{else}{/if}</strike>
            {if $product->variant->price >0}<span>{$product->variant->price|convert}</span><i>{$currency->sign|escape}</i>{else}<small class='left' title='Не назначена цена'><br />Под заказ</small>{/if}
            </div>
 
            <a class='but_add more hover_mouse' href="products/{$product->url}"></a>
            {if $product->variant->price >0}<input type="submit" class="but_add to_cart" value="" title='Купить {$product->name|escape}' data-result-text=""/>{/if}
 
            <select name="variant" {if $product->variants|count==1  && !$product->variant->name}style='display:none;'{/if}>
            {foreach $product->variants as $v}
            {if $v->price > 0}<option value="{$v->id}" {if $v->compare_price > 0}compare_price="{$v->compare_price|convert}"{/if} price="{$v->price|convert}">{$v->name}</option>{/if}
            {/foreach}
            </select>
        </form>
    {else}
        <div class="price"><small class='right' title='Нет на складе (Остаток ноль)'><br />Нет на складе</small></div>
        <a class='but_add more hover_mouse' href="products/{$product->url}"></a>
    {/if}
</div>
Ссылка на сообщение
Поделиться на другие сайты
  • 1 месяц спустя...
  • 3 года спустя...

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

Загрузка...
×
×
  • Создать...