Jump to content

Как вывести все дочерние товары из этой же категории в карточке товара


tp-20
 Share

Recommended Posts

opencart 2.1.0.1.

В карточке товара нужно вывести все товары из этой же категории. т.е. все дочерние товары.

Нашёл мануал, там выводятся вообще все товары. но взял его за основу.
подскажите, что поменять в этом коде (скриншот 1), чтобы выводились товары из текущей категории?


$results = $this->model_catalog_product->getProducts($filter_data); - в этой строке не подхватывается ID категории и выводятся вообще все имеющиеся товары. Думаю здесь в фильтре загвоздка.

Весь код целиком: (идёт в Файл controller/product/product.php )
 

$parts = explode('_', (string)$this->request->get['path']);
$category_id = (int)array_pop($parts);

$filter_data = array(
    'filter_category_id' => $category_id
);

$data['products_variant'] = array();
$results = $this->model_catalog_product->getProducts($filter_data);

foreach ($results as $result) {
   if ($result['image']) {
      $image = 'image/' . $result['image'];
   } else {
      $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
}

$data['products_variant'][] = array(
   //'category_id' => $category_id,
   'name' => $result['name'],
   'image' => $image,
   'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
}

 

Screenshot_1 (1).jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...