I want to dislay on Manufacturer list only the manufacturer that has products active. Can anyone help me?
Thank you
Code: Select all
$data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
Code: Select all
$this->load->model('catalog/product');
$filter_data['filter_manufacturer_id'] = $result['manufacturer_id'];
$products = $this->model_catalog_product->getProducts($filter_data);
if ($products) {
$data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
}
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Notice: Undefined index: manufacturer in /home/readytow/public_html/catalog/view/theme/elegantcart/template/product/manufacturer_list.tpl on line 19
Move the first four lines of code that I gave you, eg:
Code: Select all
$this->load->model('catalog/product');
$filter_data['filter_manufacturer_id'] = $result['manufacturer_id'];
$products = $this->model_catalog_product->getProducts($filter_data);
if ($products) {
Code: Select all
foreach ($results as $result) {
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
in catalog/controller/product/manufacturer.php
Find: (line 37)
Code: Select all
foreach ($results as $result) {
Code: Select all
$this->load->model('catalog/product');
$filter_data['filter_manufacturer_id'] = $result['manufacturer_id'];
$products = $this->model_catalog_product->getProducts($filter_data);
if ($products) {
$data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
}
Live with 2.2.0.0 fully SSL.
Only not working for me got this error:
Code: Select all
Undefined variable: [b]key[/b] in /public_html/webshop/vqmod/vqcache/vq2-catalog_controller_product_manufacturer.php on line 49
Live with 2.2.0.0 fully SSL.
This error is being reported from a cached vqmodded file. It's quite likely that the vQmod that you're using makes a modification at the same location, which causes the error.tjsystems wrote:Got ht epage working with the code i posted.
Only not working for me got this error:
Code: Select all
Undefined variable: [b]key[/b] in /public_html/webshop/vqmod/vqcache/vq2-catalog_controller_product_manufacturer.php on line 49
Yes!tjsystems wrote:To be clear:
in catalog/controller/product/manufacturer.php
Find: (line 37)Add after:Code: Select all
foreach ($results as $result) {
Code: Select all
$this->load->model('catalog/product'); $filter_data['filter_manufacturer_id'] = $result['manufacturer_id']; $products = $this->model_catalog_product->getProducts($filter_data); if ($products) { $data['categories'][$key]['manufacturer'][] = array( 'name' => $result['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id']) ); }
Although it would be a good idea to move:
Code: Select all
$this->load->model('catalog/product');
Code: Select all
foreach ($results as $result) {
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Undefined variable: key in /public_html/webshop/catalog/controller/product/manufacturer.php on line 42
some code from my controller:
Code: Select all
$this->load->model('catalog/product');
foreach ($results as $result) {
$filter_data['filter_manufacturer_id'] = $result['manufacturer_id'];
$products = $this->model_catalog_product->getProducts($filter_data);
if ($products) {
$data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
}
if (is_numeric(utf8_substr($result['name'], 0, 1))) {
$key = '0 - 9';
} else {
$key = utf8_substr(utf8_strtoupper($result['name']), 0, 1);
}
if (!isset($this->data['manufacturers'][$key])) {
$this->data['categories'][$key]['name'] = $key;
}
$this->data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
}
Live with 2.2.0.0 fully SSL.
Code: Select all
$this->load->model('catalog/product');
foreach ($results as $result) {
$filter_data['filter_manufacturer_id'] = $result['manufacturer_id'];
$products = $this->model_catalog_product->getProducts($filter_data);
if ($products) {
if (is_numeric(utf8_substr($result['name'], 0, 1))) {
$key = '0 - 9';
} else {
$key = utf8_substr(utf8_strtoupper($result['name']), 0, 1);
}
if (!isset($data['categories'][$key])) {
$data['categories'][$key]['name'] = $key;
}
$data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
}
}
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
This is an OC 2 support forum. Subsequently, the code provided was for OC 2.tjsystems wrote:hmm, if i use this code, no more error... Also no more manufacturers...
Any ideas? I'm using OC 1.5.6.x (Github branch)
For earlier versions of OC, the code is the same, with one exception:
Code: Select all
$data['categories'][$key]['manufacturer'][] = array(
Code: Select all
$this->data['categories'][$key]['manufacturer'][] = array(
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Ooeps my bad.. (working on two version at the moment...)fido-x wrote:This is an OC 2 support forum. Subsequently, the code provided was for OC 2.
fido-x wrote:For earlier versions of OC, the code is the same, with one exception:would be:Code: Select all
$data['categories'][$key]['manufacturer'][] = array(
Code: Select all
$this->data['categories'][$key]['manufacturer'][] = array(

[offtopic]
Sorry to say but this is one more for my in the the area of "Why a I still using Opencart...

Live with 2.2.0.0 fully SSL.
Code: Select all
$this->load->model('catalog/product');
foreach ($results as $result) {
$filter_data['filter_manufacturer_id'] = $result['manufacturer_id'];
$products = $this->model_catalog_product->getProducts($filter_data);
if ($products) {
if (is_numeric(utf8_substr($result['name'], 0, 1))) {
$key = '0 - 9';
} else {
$key = utf8_substr(utf8_strtoupper($result['name']), 0, 1);
}
if (!isset($this->data['manufacturers'][$key])) {
$this->data['categories'][$key]['name'] = $key;
}
$this->data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
}
}
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Users browsing this forum: No registered users and 6 guests