Page 1 of 1
I want Manufacturer list only with active products
Posted: Sun Oct 26, 2014 9:18 pm
by nikythebest
Hello,
I want to dislay on Manufacturer list only the manufacturer that has products active. Can anyone help me?
Thank you
Re: I want Manufacturer list only with active products
Posted: Mon Oct 27, 2014 8:46 pm
by fido-x
In "catalog/controller/product/manufacturer.php" replace the following (lines 46 to 49):
Code: Select all
$data['categories'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id'])
);
with:
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'])
);
}
and see how you go.
Re: I want Manufacturer list only with active products
Posted: Wed Oct 29, 2014 4:04 am
by nikythebest
Is not working. Giving this notice:
Notice: Undefined index: manufacturer in /home/readytow/public_html/catalog/view/theme/elegantcart/template/product/manufacturer_list.tpl on line 19
Re: I want Manufacturer list only with active products
Posted: Wed Oct 29, 2014 8:33 am
by fido-x
Sorry about that, I didn't test it properly.
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) {
to line 36, just after:
Should fix it (and I tested this one).
Re: I want Manufacturer list only with active products
Posted: Wed Oct 29, 2014 5:34 pm
by nikythebest
Thank you. You are the best.
Re: I want Manufacturer list only with active products
Posted: Wed Oct 29, 2014 5:35 pm
by nikythebest
maybe you can help me with my other problem. I am looking a home slider with right menu. Something like this:
http://www.templatemonster.com/demo/39721.html
Re: I want Manufacturer list only with active products
Posted: Wed Nov 12, 2014 4:03 am
by tjsystems
To be clear:
in catalog/controller/product/manufacturer.php
Find: (line 37)
Add after:
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'])
);
}
Re: I want Manufacturer list only with active products
Posted: Wed Nov 12, 2014 4:28 am
by tjsystems
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
Re: I want Manufacturer list only with active products
Posted: Thu Nov 13, 2014 10:39 am
by fido-x
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
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:To be clear:
in catalog/controller/product/manufacturer.php
Find: (line 37)
Add after:
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'])
);
}
Yes!
Although it would be a good idea to move:
Code: Select all
$this->load->model('catalog/product');
to before:
so that it only gets loaded once, instead of being loaded and reloaded at each iteration of the "foreach()" loop.
Re: I want Manufacturer list only with active products
Posted: Fri Nov 14, 2014 1:05 am
by tjsystems
Just disabled the vqmods for manufacturer... still same error
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'])
);
}
Re: I want Manufacturer list only with active products
Posted: Fri Nov 14, 2014 8:37 am
by fido-x
This is what the "foreach($results as $result)" loop should look with the changes:
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'])
);
}
}
Re: I want Manufacturer list only with active products
Posted: Fri Nov 14, 2014 6:10 pm
by tjsystems
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)
Re: I want Manufacturer list only with active products
Posted: Sun Nov 16, 2014 12:19 pm
by fido-x
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)
This is an OC 2 support forum. Subsequently, the code provided was for OC 2.
For earlier versions of OC, the code is the same, with one exception:
Code: Select all
$data['categories'][$key]['manufacturer'][] = array(
would be:
Code: Select all
$this->data['categories'][$key]['manufacturer'][] = array(
Re: I want Manufacturer list only with active products
Posted: Mon Nov 17, 2014 4:37 am
by tjsystems
fido-x wrote:This is an OC 2 support forum. Subsequently, the code provided was for OC 2.
Ooeps my bad.. (working on two version at the moment...)
fido-x wrote:For earlier versions of OC, the code is the same, with one exception:
Code: Select all
$data['categories'][$key]['manufacturer'][] = array(
would be:
Code: Select all
$this->data['categories'][$key]['manufacturer'][] = array(

Ok, going nuts on this... not working for me, disabled vqmod, default theme... I give up!
[offtopic]
Sorry to say but this is one more for my in the the area of "Why a I still using Opencart...

" Missing to many basic functions on the front-end.
Re: I want Manufacturer list only with active products
Posted: Mon Nov 17, 2014 9:54 am
by fido-x
This should work for you in a 1.5.6.4 setup:
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'])
);
}
}