Как я могу отобразить подкатегории с изображениями на странице категории Opencart 3 - PullRequest
0 голосов
/ 20 мая 2019

У меня настроен магазин opencart3.Как показать подкатегории с изображениями на страницах категорий?

1 Ответ

0 голосов
/ 20 мая 2019

скопируйте приведенный ниже код в файл install.xml, заархивируйте его в images_for_refine_search.ocmod.zip, установите его и не забудьте обновить модификации и очистить кеш в панели администратора ...

<?xml version="1.0" encoding="utf-8"?>
<modification>
  <name>Images for Reafine Search</name>
  <code>Images for Reafine Search</code>
  <version>1.0</version>
  <author>K.B.</author>
  <link><![CDATA[https://www.opencart.com/index.php?route=marketplace/extension&filter_member=SmartTech]]></link>



    <file path="catalog/controller/product/category.php">
    <operation error="skip">
      <search>
        <![CDATA[$data['categories'][] = array(]]>
      </search>
      <add position="before">
        <![CDATA[       
            /*images for refine search*/
            if ($result['image']) {
                $image['thumb'] = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_height'));
            } else {
                $image['thumb'] = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
            }
            /*images for refine search*/
        ]]>
      </add>
    </operation>

        <operation error="skip">
      <search>
        <![CDATA['href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)]]>
      </search>
      <add position="before">
        <![CDATA[       
            'thumb' => $image['thumb'],
        ]]>
      </add>
    </operation>
    </file>

    <!-- templates -->  
    <file path="catalog/view/theme/*/template/product/category.twig">
    <operation error="skip">
      <search>
        <![CDATA[<li><a href="{{ child.href }}">{{ child.name }}</a></li>]]>
      </search>
      <add position="replace">
        <![CDATA[       
             <div class="img-thumbnail text-center" style="margin-bottom: 10px;">
              {% if child.thumb %}
              <img src="{{ child.thumb }}" alt="{{ child.name }}" title="{{ child.name }}" class="img-responsive" />
               {% endif %}
              <a href="{{ child.href }}">{{ child.name }}</a>
             </div> 
        ]]>
      </add>
    </operation>

        <operation error="skip">
      <search>
        <![CDATA[<li><a href="{{ category.href }}">{{ category.name }}</a></li>]]>
      </search>
      <add position="replace">
        <![CDATA[       
            <div class="img-thumbnail text-center" style="margin-bottom: 10px;">
            {% if category.thumb %}
            <img src="{{ category.thumb }}" alt="{{ category.name }}" title="{{ category.name }}" class="img-responsive" />
             {% endif %}
            <a href="{{ category.href }}">{{ category.name }}</a>
            </div>
        ]]>
      </add>
    </operation>

    </file>

</modification>
...