tp-20 Posted February 22, 2025 at 08:17 PM Share Posted February 22, 2025 at 08:17 PM 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) ); } 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.