Zen Cart Logo
Forums / General Questions / Linked product - how to change the relative/parent cPath ?

Linked product - how to change the relative/parent cPath ?

Views: 538

Results 1 to 1 of 1
9 Feb 2014, 4:18 PM
#1
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Linked product - how to change the relative/parent cPath ?

Customer ID 2 can see Product ID 22 which is linked to Category ID 13 and **32.

**Product Listing returns the master_categories_id as 32 for all customers.

Customer access restriction is working properly - if you link a product to a restricted category, the product shows to the correct customer.

However when it shows up, the link is incorrect.

I need it to return the link with the master_category_id **relative **to the category it's linked in.

In the database** product_to_categories** looks like this:
Product ID **22 **Category ID 32
Product ID **22 **Category ID 13

Which will always return the master category of 32.

I need it to see that the product is actually in category 13.

Note: Changing the master category will allow Customer ID 2 to see the correct link - master category 13, but all other restricted customers will see the incorrect master category 32 link.

includes/modules/product_listing.php - line 151
This is the output code:

        $lc_text = '<h4 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h4><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';

zen_get_generated_category_path_rev($listing->fields['master_categories_id'])

This is the function that always returns the master category:
includes/functions/functions_categories.php

  function zen_get_generated_category_path_rev($this_categories_id) {
    $categories = array();
    zen_get_parent_categories($categories, $this_categories_id);

    $categories = array_reverse($categories);

    $categories_imploded = implode('_', $categories);

    if (zen_not_null($categories_imploded)) $categories_imploded .= '_';
    $categories_imploded .= $this_categories_id;

    return $categories_imploded;
  }

Help is appreciated :)