About Club osCommerce

Showcasing osCommerce - the good, the bad and the ugly!

StumbleUpon It! DIGG It!

Passing $cPath thru Advanced Search…

Written By Gary on Apr 01 2008 ·

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 :D

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 ;)


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive. Cheers!


No Comments

No comments yet.

Leave a comment

RSS feed for comments on this post · TrackBack URL

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!