Post by billynoah » Fri Jul 26, 2013 9:17 am

This code will check to see if there are no sub-categories and, if so, display products instead in the top level drop down menus. If sub-categories exist then it will use default behavior and display them in the drop down menus.

Code: Select all

<modification>
	<id>Products in Drop Down Menus</id>
	<version>1.0</version>
	<vqmver>2.1</vqmver>
	<author>billynoah@gmail.com</author>
	<file name="catalog/controller/common/header.php">
		<operation>
			<search position="before"><![CDATA[
$children = $this->model_catalog_category->getCategories($category['category_id']);
			]]></search>
			<add><![CDATA[
if ($this->model_catalog_category->getCategories($category['category_id'])) {
			]]></add>
		</operation>
		
		<operation>
			<search position="before"><![CDATA[
// Level 1
			]]></search>
			<add><![CDATA[
				} else {
                $dataProduct = array(
						'filter_category_id'  => $category['category_id'],
						'filter_sub_category' => true
					);
	            $children = $this->model_catalog_product->getProducts($dataProduct);
				foreach ($children as $child ) {
					$children_data [] = array(
							'name'  =>  $child['name'],
							'href'  => $this->url->link('product/product', 'product_id=' . $child['product_id']),
						);

                }
				}
			]]></add>
		</operation>
	</file>
</modification>
Last edited by billynoah on Mon Jan 13, 2014 12:47 am, edited 1 time in total.

Image


User avatar
Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by kamelio » Sun Jan 12, 2014 12:11 am

Excellent VQMOD RE: Display product links in main menu

Quick note: I had to close the node, seems to be a

Code: Select all

</modification>
missing from the last line.

Thanks for this mod, saved me some time ;)

Newbie

Posts

Joined
Sun Jan 12, 2014 12:07 am

Post by billynoah » Mon Jan 13, 2014 12:49 am

thanks, that was a copy/paste fail :-) I updated the original post to include the closing tag.

Image


User avatar
Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm

Post by ryanpete » Fri Jan 17, 2014 6:45 am

I love this mod thanks! I've been trying to tweak it so it will also show products under sub categories as well but I haven't had any luck.. Thoughts?

Newbie

Posts

Joined
Fri Jan 17, 2014 6:42 am

Post by raj79 » Sun Jul 13, 2014 3:23 pm

please give me live demo link ..

Online Grocery shopping in delhi


New member

Posts

Joined
Fri Jun 06, 2014 3:57 pm
Location - Delhi

Post by FedeBike » Mon Oct 12, 2015 10:39 pm

Hi all,

in which file should I copy this modification?

Thank you for your help!
Federica

Newbie

Posts

Joined
Fri Oct 02, 2015 8:21 pm

Post by pk_rulz » Thu Nov 23, 2017 3:18 am

The Mod did not work and Got this in my log. Any pointers what went wrong
SEARCH NOT FOUND (ABORTING MOD): $children = $this->model_catalog_category->getCategories($category['category_id']);

Newbie

Posts

Joined
Sun Sep 02, 2012 4:05 am

Post by pk_rulz » Thu Nov 23, 2017 3:31 am

Got it. from opencart 3 the menu is contained in a separate menu.php and no more in the header.php. Just changed header to menu in the xml and it works like a charm

Newbie

Posts

Joined
Sun Sep 02, 2012 4:05 am
Who is online

Users browsing this forum: No registered users and 4 guests