在Opencart 1.5.6.4中显示完整的面包屑

时间:2014-06-23 05:15:24

标签: html css opencart breadcrumbs

我已经安装了一个干净版本的Opencart v1.5.6.4和一个用于v1.5.5.1。现在,当您单击主页上的产品时,面包屑的行为方式之间存在差异。如果我点击主页上的产品,则为1.5.5.1版本的面包屑。是主页> category-name>产品名称,但对于版本1.5.6.4,它是主页>产品名称即可。你知道这个差异来自哪里吗?它是模板或Opencart版本中的东西还是在设置中?提前谢谢。

2 个答案:

答案 0 :(得分:2)

您可以使用VQMOD进行编辑

<modification>
<id>Always display categories in breadcrumb trail</id>
<author>Casey Faber</author>
<email>kc@caseyfaber.com</email>

<file name="catalog/model/catalog/product.php">
    <operation>
        <search position="before" index="1"><![CDATA[public function getTotalProducts($data = array()) {]]></search>
        <add><![CDATA[
    public function getCategoriesByProductId($product_id) {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");

      return $query->rows;
    }
  ]]></add>
    </operation>
</file>

<file name="catalog/controller/product/product.php">
    <operation>
        <search position="before"><![CDATA[public function upload() {]]></search>
        <add><![CDATA[
    protected function getPath($parent_id, $current_path = '') {
                $category_info = $this->model_catalog_category->getCategory($parent_id);

                if ($category_info) {
                    if (!$current_path) {
                        $new_path = $category_info['category_id'];
                    } else {
                        $new_path = $category_info['category_id'] . '_' . $current_path;
                    }   

                    $path = $this->getPath($category_info['parent_id'], $new_path);

                    if ($path) {
                        return $path;
                    } else {
                        return $new_path;
                    }
                }
            }
  ]]></add>
    </operation>
    <operation>
        <search position="after"><![CDATA[if ($product_info) {]]></search>
        <add><![CDATA[
    if(!isset($category_info)) {
      $categories = $this->model_catalog_product->getCategoriesByProductId($this->request->get['product_id']);
      if($categories) {
        foreach($categories as $category){
          $path = $this->getPath($category['category_id']);
          $category_info = $this->model_catalog_category->getCategory($category['category_id']);
          if($path){
            $cat_path = $path;
          }else{
            $cat_path = $category_info['category_id'];
          }

          if($category_info) {
            $path = '';
            foreach (explode('_', $cat_path) as $path_id) {
              if (!$path) {
                $path = $path_id;
              } else {
                $path .= '_' . $path_id;
              }

              $category_info = $this->model_catalog_category->getCategory($path_id);

              if ($category_info) {
                $this->data['breadcrumbs'][] = array(
                  'text'      => $category_info['name'],
                  'href'      => $this->url->link('product/category', '&path=' . $path),
                  'separator' => $this->language->get('text_separator')
                );
              }
            }
            break;
          }

        }
      }
    }
  ]]></add>
    </operation>
</file>

答案 1 :(得分:0)

在类别产品网址上:

  ?

路线=产品/产品&安培;路径= 18&安培; PRODUCT_ID = 47

首页产品网址:

  ?

路线=产品/产品&安培; PRODUCT_ID = 47

when category page to display full breadcrumb with category 
name using " path=18 " get category id 18 to name. 

Full breadcrumb url使用此功能,您可以获得主页产品或其他地方的完整面包屑。

enter image description here

How to install vqmode