Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Вывод атрибутов вместо описания в категориях


ingenerks
 Share

Recommended Posts

4 часа назад, StivenLight сказал:

$data['products'][] = array( 'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),

это, в каком файле сделали?

Link to comment
Share on other sites

  • 1 year later...
24.12.2016 в 10:43, Tom сказал:

Похвально,что в начале была хотя бы попытка найти решение.
 
В контроллер category.php  после  

$data['products'][] = array(

добавить

'attribute_groups' => $this->model_catalog_product->getProductAttributes($result['product_id']),

в шаблон категории в нужном месте в виде списка атрибутов
 

<p>
<?php if ($product['attribute_groups']) { ?>
<?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
<strong><?php echo $attribute_group['name']; ?>:</strong>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<span><?php echo $attribute['name']; ?>:</span> <?php echo $attribute['text']; ?><br />   
<?php } ?>
<?php } ?>
<?php } ?>
</p>

 или таблицей вариант 2

<p>
  <?php if ($product['attribute_groups']) { ?>
<div class="tab-pane" id="tab-specification">
  <table class="table table-bordered">
    <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
    <thead>
    <tr>
      <td colspan="2"><strong><?php echo $attribute_group['name']; ?></strong></td>
    </tr>
    </thead>
    <tbody>
    <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
    <tr>
      <td><?php echo $attribute['name']; ?></td>
      <td><?php echo $attribute['text']; ?></td>
    </tr>
    <?php } ?>
    </tbody>
    <?php } ?>
  </table>
</div>
<?php } ?>
</p>

или в одну строку,через слеш вариант 3

 

<p>
<?php if ($product['attribute_groups']) { ?>
<?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
<strong><?php echo $attribute_group['name']; ?>:</strong>
<?php foreach ($attribute_group['attribute'] as $attribute) { ?>
<span><?php echo $attribute['name']; ?>:</span> <?php echo $attribute['text']; ?> /   
<?php } ?>
<?php } ?>
<?php } ?>
</p>

У меня выдает ошибку  Notice: Undefined variable: product in /system/storage/modification/catalog/view/theme/luxshop/template/product/category.tpl on line 201

Link to comment
Share on other sites


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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.