In the official osCommerce Forum, someone asked for the ability to pass the $cPath variable through the Advanced Search Result “link” for each product.
Basically, instead of a direct link to a product, eg: product_info.php?products_id=10, he wanted product_info.php?cPath=3_11&products_id=10
The example obviously assumes that Product 10, is inside Subcategory 11 which is inside Category 3. Got that 😀
The code changes are minimal. There’s only two files to change and it goes like this:
advanced_search_result (about line 207)
Find this:
$select_str = “select distinct ” . $select_column_list . ” m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price “;
Change to:
$select_str = “select distinct ” . $select_column_list . ” m.manufacturers_id, p.products_id, p2c.categories_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price “;
/includes/modules/product_listing.php (about line 90)
Find this:
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
$lc_align = ”;
Right below it, add:
if (tep_not_null($listing[‘categories_id’])) {
$cPath = tep_get_product_path($listing[‘categories_id’]);
}
Done! Save the files, upload and test the product links. Feel free to Paypal me a donation if you find it useful 😉
Advanced_search_result is returning the incorrect cpath. For example, it returns a cpath of 37_54 when the correct cpath is 72_398_80.
I suspect it must be one of the category functions, but they all look correct when compared to the stock install.
Any pointers on where to start?
Good spot. Forget the change in the advanced_search file. In the listing module, just make this code change in place of the other;
if (tep_not_null($listing[‘products_id’])) {
$cPath = tep_get_product_path($listing[‘products_id’]);
}