Post by marc_cole » Mon Jan 24, 2011 8:59 am

I'm stuck. :-\ I'm trying to replace the categories pull-down menu on the search page with one that shows all manufacturers. I've got it to display the menu properly, but when I select a manufacturer from the list, no products are found. However, if I select All Manufacturers from the list, the item is found.

I just can't figure out where to go from here. Any help with the PHP will be greatly appreciated.

You'll find the latest vQmod file in the last post in this thread, and I'll post the final result here when finished for everyone to download.

Thanks,
Marc
Last edited by marc_cole on Tue Jan 25, 2011 1:23 pm, edited 3 times in total.

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by justinv » Mon Jan 24, 2011 12:00 pm

I'd like to see the search page itself if possible?

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by Xsecrets » Mon Jan 24, 2011 1:23 pm

looked at it quickly, and didn't see where you made any changes to the products.php model file. That is where the actual db query is performed and it doesn't have manufacurer_id in it so it will have to be changed for that to ever work.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by marc_cole » Mon Jan 24, 2011 1:56 pm

I'm not sure I follow you. Shouldn't the following two functions be enough to work?

getProductsByManufacturerId
getTotalProductsByManufacturerId

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by marc_cole » Tue Jan 25, 2011 3:48 am

Xsecrets wrote:...products.php model file ... it doesn't have manufacurer_id in it...
O.K. Not sure if this is what you were referring to, but I updated getProductsByKeyword and it still doesn't work.
Last edited by marc_cole on Tue Jan 25, 2011 8:12 am, edited 1 time in total.

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by Xsecrets » Tue Jan 25, 2011 5:49 am

you didn't update it correctly. from your file

Code: Select all

if ($ manufacturer_id) {
				$data = array();
				
				$this->load->model('catalog/manufacturer');
				
				$string = rtrim($this->getPath($ manufacturer_id), ',');
				
				foreach (explode(',', $string) as $ manufacturer_id) {
					$data[] = " manufacturer_id = '" . (int)$ manufacturer_id . "'";
				}
				
				$sql .= " AND p.product_id IN (SELECT product_id FROM product_to_category WHERE " . implode(" OR ", $data) . ")";
			}
the manufacturer id's won't be found in the product_to_category table.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by marc_cole » Tue Jan 25, 2011 8:11 am

Xsecrets wrote:the manufacturer id's won't be found in the product_to_category table.
Yep, you're right — I missed that. Unfortunately, it didn't help.

I made some other changes but I feel like I'm getting nowhere. Enclosed is version 3. Hopefully I'm getting closer.

Attachments


OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by Xsecrets » Fri Jan 28, 2011 3:05 am

in the model file try replacing

Code: Select all

if ($manufacturer_id) {
				$this->load->model('catalog/manufacturer');
				
				$string = $this->getManufacturer($manufacturer_id);
				$sql .= " AND p.product_id IN (SELECT product_id FROM product WHERE " . $string . ")";
			}
with

Code: Select all

if ($manufacturer_id) {
				$sql .= " AND p.manufacturer_id = '" . $manufacturer_id . "'";
			}

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by marc_cole » Fri Jan 28, 2011 3:38 am

Xsecrets wrote:in the model file try replacing...
Thanks for the tip. Unfortunately, it doesn't change anything. I had tried a few different combinations like the one you sent, but to no avail.

That section of code is not being called, apparently. I echoed out the function getProductsByKeyword, and when I enter a product ID in the search box and click the upper 'Search' button, it echoes this:

Code: Select all

SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM review r 
WHERE p.product_id = r.product_id 
GROUP BY r.product_id) AS rating FROM product p 
LEFT JOIN product_description pd ON (p.product_id = pd.product_id AND pd.language_id = '1') 
LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id AND p2s.store_id = '0') 
LEFT JOIN manufacturer m ON (p.manufacturer_id = m.manufacturer_id) 
LEFT JOIN stock_status ss ON (p.stock_status_id = ss.stock_status_id AND ss.language_id = '1') 
WHERE pd.language_id = '1' AND (LCASE(pd.name) LIKE '%s2448c%' OR LCASE(p.model) LIKE '%s2448c%') AND p.status = '1' AND p.date_available <= NOW() 
GROUP BY p.product_id 
ORDER BY LCASE(p.model) ASC LIMIT 0,8
However, when I select a mfg and click the lower 'Search' button, nothing is echoed and no products are found. What's interesting, though, is if I then select All Manufacturers from the list and click the lower 'Search' button, the SQL is echoed out again and the products are found.

Marc

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by afwollis » Sat Jan 29, 2011 4:25 pm

marc_cole, I have downloaded xml file but still have not vqmod installed =)

So before I started I wanna ask:
why do you want replace categories?
what about just add manufacturers?

I will post fixed xml as soon as possible :)

Русское коммьюнити разработчиков OpenCart - myopencart.ru

some useful mods:
[Released] Orders and Comments AT-A-GLANCE, [Released] Prof. Invoice and Packingslip, [Released] Recently viewed

My commercial modules: [W]ebme Compare Products, [W]ebme Bought With This


Active Member

Posts

Joined
Tue Jan 11, 2011 5:41 am
Location - Ukraine

Post by marc_cole » Sat Jan 29, 2011 11:35 pm

afwollis wrote:why do you want replace categories?
what about just add manufacturers?
That could work. For me, I was just going to replace the categories since we have about 1,000 of them and people probably wouldn't know which one a product was in anyway.

Thanks,
Marc
Last edited by marc_cole on Wed Feb 02, 2011 9:51 am, edited 1 time in total.

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by afwollis » Tue Feb 01, 2011 3:05 pm

Marc, you forgot about, at least, one function:

Code: Select all

public function getTotalProductsByKeyword($keyword, $category_id = 0, $description = FALSE, $model = FALSE) {
try to use attached xml-file

UPD
removed all debug-prints from xml

Attachments

modified xml-file for vqmod


Русское коммьюнити разработчиков OpenCart - myopencart.ru

some useful mods:
[Released] Orders and Comments AT-A-GLANCE, [Released] Prof. Invoice and Packingslip, [Released] Recently viewed

My commercial modules: [W]ebme Compare Products, [W]ebme Bought With This


Active Member

Posts

Joined
Tue Jan 11, 2011 5:41 am
Location - Ukraine

Post by marc_cole » Wed Feb 02, 2011 9:49 am

afwollis wrote:Marc, you forgot about, at least, one function:
That did it. Thanks, afwollis! I appreciate your help.

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA
Who is online

Users browsing this forum: No registered users and 10 guests