请告诉我如何在产品页面上显示产品所属类别的图像。我拿出了类别的名称和链接,但使用图像它不起作用。我不明白要插入什么以及在哪里显示类别图像。我这样做了(在 OCMOD 文件中):
<file path="catalog/controller/product/product.php">
<operation error="log">
<search><![CDATA[$product_info = $this->model_catalog_product->getProduct($product_id);]]></search>
<add position="after" index="1"><![CDATA[
$query_linked_categories = $this->model_catalog_product->getCategories($product_id);
$linked_categories = array();
foreach( $query_linked_categories as $linked_category_data ) {
$linked_category = $this->model_catalog_category->getCategory($linked_category_data['category_id']);
$linked_category_info['id'] = $linked_category_data['category_id'];
$linked_category_info['href'] = $this->url->link('product/category', 'path=' . $linked_category_data['category_id']);
$linked_category_info['name'] = $linked_category['name'];
$linked_categories[] = $linked_category_info;
}
]]></add>
</operation>
<operation error="log">
<search><![CDATA[$data['manufacturer'] = $product_info['manufacturer_name'];]]></search>
<add position="before"><![CDATA[
$data['linked_categories'] = $linked_categories;
]]></add>
</operation>
<file path="catalog/view/theme/*/template/product/product.twig">
<operation error="log">
<search><![CDATA[<li>{{ text_model }} {{ model }}</li>]]></search>
<add position="before"><![CDATA[
{% if linked_categories %}
<div class="uni-module product-linked_categories">
<div class="category-list row row-flex">
{% for linked_category in linked_categories %}
<div>
<a href="{{ linked_category.href }}" class="category-list__item image-after">
{% if linked_category.thumb %}
<img src="{{ linked_category.thumb }}" alt="{{ linked_category.name }}" title="{{ linked_category.name }}" class="category-list__img img-responsive" />
{% endif %}
{{ linked_category.name }}
</a>
</div>
{% endfor %}
</div>
</div>
<script>
$('.product-linked_categories').uniModules({
type:'{{type_view is defined ? type_view : 'carousel'}}',
loop: {{linked_categories|length > 4 ? 'true' : 'false'}}
});
</script>
{% endif %}
]]></add>
</operation>
</file>