Thread: Porting OsC mod

Results 1 to 8 of 8
  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Porting OsC mod

    Getting a little deep in this mod for a client who simply wants her old inventory update mod.

    Easy enough to change tep to zen and to put in replace if bits but I have foreach situation and I need help resolving this. This is the section I'm converting. I know the foreach line does not work due to the array_keys

    PHP Code:
        $categories = array();

        
    // Consolidate the below into a join, so we can alphabetise, among other things.

        
    $categories $db->Execute("SELECT c.categories_id, c.parent_id, cd.categories_name FROM categories AS c, categories_description AS cd WHERE c.parent_id > 0 AND cd.categories_id = c.categories_id ORDER BY cd.categories_name ASC");


        
    // Buffer the categories.

        
    while($categories->EOF) {

            
    $categories[] = array('id' => $category['categories_id'],
                          
    'parent_id' => $category['parent_id'],
                          
    'name' => $category['categories_name']);
    $categories->MoveNext();
        }

        echo 
    zen_draw_form('products_update''riu.php''action=process');

        foreach(
    array_keys($categories) as $category) {

            
    $categories_products_query $db->Execute("SELECT products_id FROM products_to_categories WHERE categories_id = " $categories[$category]['id']);

            if(
    $categories_products_query->RecordCount()) { 
    The error message is array_keys() expects parameter 1 to be array, object given in...

    I've seen some examples of how to change this but just not sure and what I've tried hasn't worked. Could be due to how the section is set up before we get that far - I just don't know.

    Would someone check the php for this to push me in the right direction? Any help would be appreciated.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Porting OsC Inventory mod

    Quote Originally Posted by delia View Post
    Code:
    $categories = $db->Execute("SELECT c.categories_id, c.parent_id, cd.categories_name FROM categories AS c, categories_description AS cd WHERE c.parent_id > 0 AND cd.categories_id = c.categories_id ORDER BY cd.categories_name ASC"); 
    
    
        // Buffer the categories. 
    
        while($categories->EOF) { 
    
            $categories[] = array('id' => $category['categories_id'], 
                          'parent_id' => $category['parent_id'], 
                          'name' => $category['categories_name']); 
    $categories->MoveNext(); 
        } 
    
    You are using $categories for three things there, and $category for nothing.
    Change that to this:
    Code:
    $result = $db->Execute("SELECT c.categories_id, c.parent_id, cd.categories_name FROM categories AS c, categories_description AS cd WHERE c.parent_id > 0 AND cd.categories_id = c.categories_id ORDER BY cd.categories_name ASC"); 
        // Buffer the categories. 
    
        while($result->EOF) { 
    
            $categories[] = array('id' => $result['categories_id'], 
                          'parent_id' => $result['parent_id'], 
                          'name' => $result['categories_name']); 
            $result->MoveNext(); 
        }
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: Porting OsC Inventory mod

    Thought my eyes were crossing for some reason! So that fixed the error - mod still doesn't display product list but has no errors and trying to convince client to use apsona instead.

    She does have a interesting point though - being able to update quantities in very easy manner - would be nice to have for some folks. Be glad to turn these files over to anyone who would like to give it a try.

    Oh, and thanks, Dr Byte, much appreciated!
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Porting OsC Inventory mod

    Quote Originally Posted by DrByte View Post
    Code:
            $categories[] = array('id' => $result['categories_id'], 
                          'parent_id' => $result['parent_id'], 
                          'name' => $result['categories_name']);
    Oops, those should have been $result->fields
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: Porting OsC Inventory mod

    ah, I don't understand. Yes, the rows are not printing out.

    And yeah, now she says she really wants this done.

    Methinks I'm going to recognize it when I see it done right....

    I do usually go find a like mod or file and can figure out from there. Suggestion? I don't mind puzzling it out if I got solid code to follow or utilize.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Porting OsC Inventory mod

    These:
    Code:
            $categories[] = array('id' => $result['categories_id'], 
                          'parent_id' => $result['parent_id'], 
                          'name' => $result['categories_name']);
    need to be written:
    Code:
            $categories[] = array('id' => $result->fields['categories_id'], 
                          'parent_id' => $result->fields['parent_id'], 
                          'name' => $result->fields['categories_name']);
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: Porting OsC Inventory mod

    Okay, that looks right!

    Then I got a foreach for the categories and a while statement for the products and they obviously aren't correct.

    I have to start fresh in the morning - my brain has quit and I don't want to rely on your brain(s) completely as that's just not fair!

    I thank you for your time today.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  8. #8
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: Porting OsC Inventory mod

    Looks like I've only one more hurdle to at least get the page to print out correctly. So the array inside the category array is the problem.

    I can get all the categories to display but only one product for each category so this is not running thru the array:
    PHP Code:
    $products_query $db->Execute("SELECT p.products_id, pd.products_name, p.products_quantity, DATE_FORMAT(p.products_date_available, '%m-%d-%Y') AS products_date_available "
                                
    .      "FROM products AS p, products_description AS pd WHERE p.products_id = pd.products_id AND p.products_id = " $categories_products_query->fields['products_id']);

    while(!
    $products_query->EOF) {    

                    

                        echo 
    "        <tr>\n"
                        
    .    "          <td valign=\"top\" align=\"left\" width=\"50%\" class=\"dataTableContent\">\n"
                        
    $products_query->fields['products_name']
                        .    
    "          </td>\n"
                        
    .    "        <td valign=\"top\" align=\"right\" width=\"20%\" class=\"dataTableContent\">\n"
                        
    zen_draw_input_field('product_qty_' $products_query->fields['products_id'], $products_query->fields['products_quantity'], 'maxlength=10, size=7'false$type 'text'false)
                        .    
    "            </td>\n"
                        
    .    "            <td valign=\"top\" align=\"right\" width=\"30%\" class=\"dataTableContent\">\n"
                        
    zen_draw_input_field('product_date_available_' $products_query->fields['products_id'], 
                                isset(
    $products_query->fields['products_date_available']) ? 
                                   
    $products_query->fields['products_date_available'] : "now",
                                
    'maxlength=15, size=10'false$type 'text'false)
                        .    
    "        </td>\n"
                        
    .    "        </tr>\n";
                        
    // this marks the end of the movement thru the while statement.                    
    $products_query->MoveNext(); 
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

 

 

Similar Threads

  1. Problems porting OSC Merchant Partners Mod
    By dbltoe in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 15 May 2008, 07:33 PM
  2. OSC mod porting - more help please - another code problem
    By strelitzia in forum Contribution-Writing Guidelines
    Replies: 0
    Last Post: 31 Oct 2007, 07:34 PM
  3. Porting modules from OSC
    By strelitzia in forum Contribution-Writing Guidelines
    Replies: 0
    Last Post: 27 Sep 2007, 07:32 PM

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