Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2019
    Location
    Canada
    Posts
    2
    Plugin Contributions
    0

    bug zen_get_categories_products_list() returns an array of the same categoryId

    After implementing this function into my website, I figured the function was returning the category Id over and over again depending on the number of products in that category. This line was the problem:
    Code:
     $categories_products_id_list[$products->fields['products_id']] = $current_cPath;
    I simply changed it to
    Code:
     $categories_products_id_list[]=$products->fields['products_id'];
    It was obviously adding the current_cPath variable over and over in the array at the product id position.

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,696
    Plugin Contributions
    123

    Default Re: zen_get_categories_products_list() returns an array of the same categoryId

    I am not finding the referenced line in Zen Cart 1.5.6 - can you be specific about which file/line you believe to be in error?
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: zen_get_categories_products_list() returns an array of the same categoryId

    Quote Originally Posted by swguy View Post
    I am not finding the referenced line in Zen Cart 1.5.6 - can you be specific about which file/line you believe to be in error?
    Take a look at the file includes/functions/functions_categories.php line 502. This is the line to which it appears the OP is referencing.

    However, it also appears that the functionality of what is provided is not understood. It seems that the use attempted by the OP is to always use the result ($value) of the array when really the key ($key) is likely what is needed as if the use code was something like:
    Code:
    $myList = zen_get_categories_products_list($this_Category);
    foreach ($myList as $val) {
     echo 'I expect that the products_id will be output here: ' . $val . ' but oops, this is the category path.' . PHP_EOL;
    }
    Instead of:
    Code:
    $myList = zen_get_categories_products_list($this_Category);
    foreach ($myList as $key => $val) {
     echo 'I expect that the products_id will be output here: ' . $key . ' and if I need the category path it is: ' . $val . PHP_EOL;
    }
    Similar code is in the admin side. If the proposed change were made on the catalog side, then this would affect the display of specials, sales, new product, and featered product. On the admin, I didn't look as hard, but don't see why it should be modified where it appears the goal of the OP is to identify the individual products_id that are provided and that there is no interest in the categories associated with that product.

    Just my evaluation of what was posted and what the function does. I think when I first saw it I thought it unusual when inspecting the last category of a category tree, but once a category above that was used/referenced, it somewhat made more sense, a way to reference a product to its category without having to requery the database once the array was created where the array could include every product in the database.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Aug 2019
    Location
    Canada
    Posts
    2
    Plugin Contributions
    0

    Default Re: zen_get_categories_products_list() returns an array of the same categoryId

    You are correct. Sorry about that post. I'm still learning php playing with the code. That exemple in the comments above the function played with my head when it declared the variable as an Array(). I'm still used to other languages using arrays and dicts. Thank you for pointing out my mistake.

 

 

Similar Threads

  1. force my pictures show the same width and the same height
    By win8win in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 7 Oct 2012, 04:19 PM
  2. Warning: array_merge() [function.array-merge]: Argument #1 is not an array
    By antieuclid in forum PayPal Express Checkout support
    Replies: 3
    Last Post: 19 Jul 2010, 02:50 AM
  3. Replies: 19
    Last Post: 14 Dec 2009, 01:17 PM
  4. Replies: 1
    Last Post: 14 Mar 2008, 02:58 AM
  5. 2 stores on the same site using the same paypal account, potential problems?
    By nigelt74 in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 5 Dec 2007, 10:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR