douyiqi9640 2015-05-20 14:32
浏览 54

Opencart显示相关产品的属性

I need help with a loop in opencart.

I want to display 2 - 3 product next to each other other on the product page. similar to how products are displayed in on the compare page. I've achieved the product limit via code already and I've managed to display everything else, pictures, price etc. My issue is the attributes.

I know that i need to reach into this array

$this->data['products'][] = array(
......
'attribute'    => $attribute_data,

I've also included this line of code

$attribute_groups =  $this->model_catalog_product->getProductAttributes($product_id);

my loop is

<?php foreach ($attribute_group['attribute'] as $key => $attribute) { ?>
<tbody>
  <tr>

    <td><?php echo $attribute['name']; ?></td>

      <td><?php echo $attribute['text']; ?></td>


  <?php } ?>
<?php } ?> 

This gets me all attributes of the current product but displays errors for any attributes not filled in if there are any related products.

Then I have no idea on how to reach into the array and display the related product attribute details.

please help

  • 写回答

1条回答 默认 最新

  • douzhe9927 2015-05-21 14:00
    关注
    <?php if isset($attribute['name'];); {?>
    
    <td><?php echo $attribute['name']; ?></td>
    
    <?php } ?>
    

    Try this; the error will not be shown.

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法