Post by nikythebest » Sun Oct 26, 2014 9:18 pm

Hello,

I want to dislay on Manufacturer list only the manufacturer that has products active. Can anyone help me?

Thank you

New member

Posts

Joined
Thu Sep 15, 2011 3:54 am

Post by fido-x » Mon Oct 27, 2014 8:46 pm

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.

Image
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!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by nikythebest » Wed Oct 29, 2014 4:04 am

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

New member

Posts

Joined
Thu Sep 15, 2011 3:54 am

Post by fido-x » Wed Oct 29, 2014 8:33 am

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:

Code: Select all

foreach ($results as $result) {
Should fix it (and I tested this one).

Image
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!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by nikythebest » Wed Oct 29, 2014 5:34 pm

Thank you. You are the best.

New member

Posts

Joined
Thu Sep 15, 2011 3:54 am

Post by nikythebest » Wed Oct 29, 2014 5:35 pm

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

New member

Posts

Joined
Thu Sep 15, 2011 3:54 am

Post by tjsystems » Wed Nov 12, 2014 4:03 am

To be clear:

in catalog/controller/product/manufacturer.php

Find: (line 37)

Code: Select all

foreach ($results as $result) {
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'])
				);
			}

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam

Post by tjsystems » Wed Nov 12, 2014 4:28 am

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

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam

Post by fido-x » Thu Nov 13, 2014 10:39 am

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)

Code: Select all

foreach ($results as $result) {
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:

Code: Select all

foreach ($results as $result) {
so that it only gets loaded once, instead of being loaded and reloaded at each iteration of the "foreach()" loop.

Image
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!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by tjsystems » Fri Nov 14, 2014 1:05 am

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'])
			);
		}

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam

Post by fido-x » Fri Nov 14, 2014 8:37 am

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'])
		);
	}
}

Image
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!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by tjsystems » Fri Nov 14, 2014 6:10 pm

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)

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam

Post by fido-x » Sun Nov 16, 2014 12:19 pm

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(

Image
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!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by tjsystems » Mon Nov 17, 2014 4:37 am

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(
:bash: 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.

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam

Post by fido-x » Mon Nov 17, 2014 9:54 am

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'])
		);
	}
}

Image
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!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia
Who is online

Users browsing this forum: No registered users and 18 guests