Forums / Upgrading from 1.3.x to 1.3.9 / Product - Master Category problem

Product - Master Category problem

Locked

Views: 12,467

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
4 Dec 2006, 6:46 AM
#1
quentinjs avatar

quentinjs

Zen Follower

Join Date:
Mar 2004
Location:
Calgary, Alberta
Posts:
289
Plugin Contributions:
0

Product - Master Category problem

Along the way I believe thhe "Master Category" was added to the system. I am not sure how my problem occured, but I have a lot of products with a Master Category of 0. Some are linked cats, others are not.

If its a linked cat I can select the proper cat from the list, but for the ones that arent I don't have an easy way to fix this. Is there a script for updating the master categories. I'm using ZC 1.3.6

4 Dec 2006, 4:00 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Product - Master Category problem

  1. do a full database backup of your mysql data
  2. Admin->Tools->Store Manager ---->Reset ALL Products Master Categories ID

.
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 Dec 2006, 6:11 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Product - Master Category problem

Note: if you reset the Master Categories ID ... you then want to run the Update Products Price Sorter as well ...

WARNING: if you are using Linked Products ... be careful!! Updating the Master Categories ID will select the first categories_id found in the products_to_categories table as the master_categories_id

If you are missing master_categories_id from the products table it sounds like you are importing products ...

If you are not importing and missing this setting on the products then you have something messed up in the code on your Admin ...

This is all managed as files are added, edited, moved, etc. for you ...

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!

5 Dec 2006, 6:25 AM
#4
quentinjs avatar

quentinjs

Zen Follower

Join Date:
Mar 2004
Location:
Calgary, Alberta
Posts:
289
Plugin Contributions:
0

Re: Product - Master Category problem

Well I haven't been importing products, I was leary of doing that and messing things up in a nasty way.

The new products added are working, these are ones added with 1.26 or earlier I believe. Also I run PHP 5 / MYSQL 5 which could be part of thhe problem as I did have troubles with copying products as well.

5 Dec 2006, 5:35 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Product - Master Category problem

All of those things could contribute to the problem ...

Did the updates on master_categories_id and products_price_sorter fix these issues?

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!

5 Dec 2006, 6:37 PM
#6
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Product - Master Category problem

Recent versions of the quick_updates mod have the option to view and update your master cats quickly.

latest version can currently be found here:
http://www.zen-cart.com/forum/showpost.php?p=296321&postcount=153

15 Dec 2006, 12:59 AM
#7
bettysue avatar

bettysue

Inactive

Join Date:
May 2004
Posts:
747
Plugin Contributions:
0

Re: Product - Master Category problem

Hi,
I also just noticed a problem with "invalid master category id" in a store that was upgraded from v1.35 to 1.36 (files uploaded, upgrade was db upgrade).

However in addition to the products giving the invalid master id error, they also have this error message at the top of the product edit screen:

Warning: reset() [function.reset]: Passed variable is not an array or object in /my/path/edited/for/security/admin/includes/classes/object_info.php on line 29

Warning: Variable passed to each() is not an array or object in /my/path/edited/for/security/admin/includes/classes/object_info.php on line 30

the object_info.php file has not been modified. Also when looking at the product in the product edit screen the description is gone.

Any suggestions as to where to begin searching for a fix to this error?

betty

6 Mar 2007, 1:01 PM
#8
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: Product - Master Category problem

I have exactly the same error messages as reported by Betty. I have looked at the Products table within the database and the Master Category ID seems to be set correctly. There is nothing obvious missing.

I am running v 1.3.5

I have this problem with just a few products - not all.

The products display correctly in the Catalogue and customers appear to be able to order OK. It's just when I try to edit the product details in Admin that the error appears. The products have probably been copied and moved over time so the cause may be related to this - but others that have been copied and/or moved do not exhibit the problem.

Resetting the Master Categoies ID does not solve the problem.

Any ideas anyone?

Thanks,

Alan

workingIT.co.uk
working IT for business

8 Mar 2007, 3:57 AM
#9
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,843
Plugin Contributions:
17

Re: Product - Master Category problem

Don't know if it will help but we created the problem for ourselves by changing the product_type in the database. When we changed it back, the error in Admin went away.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

19 Apr 2007, 12:02 PM
#10
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: Product - Master Category problem

I can now replicate this problem so I now think I know the cause.

If a product has been copied (linked) from one category to another and it is decided to delete the product from the master category but not from the secondary category then in Admin

Catalog>Categories/Products>Master Category>Product

if you click on the delete button (red x) you are then given a choice of which copy of the product you wish to delete. If you choose to delete the copy in the Master Category (tick the box) but not the copy in the secondary category (un-tick the box) and then click 'Delete' the copy of your product in the Master Category will be deleted but the copy in the secondary category will still be there. If you now go to the secondary category and try to edit it you will get the following error:

Warning: reset(): Passed variable is not an array or object in /home/1256/tester/rcm.testingit.net/public_html/admin/includes/classes/object_info.php on line 29

Warning: Variable passed to each() is not an array or object in /home/1256/tester/rcm.testingit.net/public_html/admin/includes/classes/object_info.php on line 30 

and none of your product details will appear in the edit product screen.

Fortunately the product will still appear in the catalog and customers will still be able to purchase it.

In the database you will find that in the 'products' table the 'master_categories_id' is set to the categories_id of the category the product has just been deleted from whereas in the products_to_categories table you will find that the products_id is only linked to the secondary categories_id, the entry linking the product to the master categories_id having been deleted by the above action.

Changing the master_categories_id in the products table to match the categories_id linked to the product_id in the products_to_categories table does not solve the problem. Neither does resetting all Products Master Categories and Products Price Sorter in the Store Manager which in essence does the same thing.

I know that the above action should not be carried out - and there are plenty of warnings in big red letters - but that hasn't stopped my client!

Anyone any idea how to put this right?

Regards,

Alan

workingIT.co.uk
working IT for business

19 Apr 2007, 5:24 PM
#11
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: Product - Master Category problem

OK I've done some more testing and now know the cause - and the solution!

Firstly apologies to my client - this problem is caused by deleting any linked product - not just the one in the master category so it will happen even if you are doing everything correctly.

Secondly I was having this problem with the Moku contribution Product-Book product type so I was beginning to suspect that this was a contribution error rather than a core problem. This doesn't happen with a Product-General product type but it does with a Product-Music product type and the Product-Music type product is part of the core distribution so I will explain the cause, the fix and the recovery strategy for this product type.

THE CAUSE:

The problem lies in

/admin/includes/modules/product_music/delete_product_confirm.php

This is a copy of this file

/admin/includes/modules/delete_product_confirm.php

which is the default file that is used if there is no product type specific file available.

There is a section set aside in the middle of the code where the product specific code is to be placed and for the music product file this section contains code which deletes the product type specific data stored in the product_music_extra table and the media_to_products table.

What happens when a linked product is deleted is that this section of code is run and the product type specific data is deleted regardless that the master category copy of the product still exists. When a subsequent attempt is made to edit the product some of the data is found to be missing and the error described above occurs.

THE FIX:

The non- code way of preventing this is to use Multiple Categories Link Manager when linking and un-linking products. The link to this is at the bottom of the sidebox that opens when the copy icon is clicked next to the product listing (the blue spot with the letter 'c') Here products can be link and unlinked to as many categories as required without this problem ever occuring - and without the Master Category copy being deleted by mistake.

To correct the code in

/admin/includes/modules/product_music/delete_product_confirm.php

the problem is that the code placed between the

--PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__BELOW_HERE--

and

--PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__ABOVE__HERE--

should not actually go there at all!

This is the last section of the code in this file:

    // if not linked to any categories, do delete:
    if ($count_categories->fields['total'] == '0') {
      zen_remove_product($product_id, $delete_linked);
    }

  } // endif $do_delete_flag

  // if this is a single-product delete, redirect to categories page
  // if not, then this file was called by the cascading delete initiated by the category-delete process
  if ($action == 'delete_product_confirm') zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

The product type specificcode should actually be placed between the markers as shown here:

    // if not linked to any categories, do delete:
    if ($count_categories->fields['total'] == '0') {
      zen_remove_product($product_id, $delete_linked);

--PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__BELOW_HERE--


--PRODUCT_TYPE_SPECIFIC_INSTRUCTIONS_GO__ABOVE__HERE--

    }

  } // endif $do_delete_flag

  // if this is a single-product delete, redirect to categories page
  // if not, then this file was called by the cascading delete initiated by the category-delete process
  if ($action == 'delete_product_confirm') zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

THE RECOVERY STRATEGY

The problem products_id needs to be placed into the product_music_extra table of the database using the following sql

INSERT INTO `product_music_extra` ( `products_id` , `artists_id` , `record_company_id` , `music_genre_id` ) 
VALUES (
'xxx', '0', '0', '0'
);

Replace 'xxx' with the appropriate products_id.

It would appear that the media-to_products table is not used so this can be ignored.

Once this is done the problem will be cleared and it will be possible to edit the product again. The product type specific data that was lost can now be re-entered using the edit screen.

Looks like I've found a bug!

Hope this helps if you have come across this problem.

Regards,

Alan

workingIT.co.uk
working IT for business

22 Apr 2009, 2:44 PM
#12
jeet_kune_do avatar

jeet_kune_do

Zen Follower

Join Date:
Nov 2008
Location:
Slovenija
Posts:
119
Plugin Contributions:
0

Re: Product - Master Category problem

I have 4 languages.
I have a categories, a subcategories and products.
When i click on one subcategory for the Slovene language, i have "no products find" , but for other languages it works.

What could it be?

And when I click to some subcategory it bring me to one different product in different category.

In past I installed Easy populate, but than I did a Full Back Up.

Please Help

I love internet and the power of information... Best Wishes!!

22 Apr 2009, 3:06 PM
#13
jeet_kune_do avatar

jeet_kune_do

Zen Follower

Join Date:
Nov 2008
Location:
Slovenija
Posts:
119
Plugin Contributions:
0

Re: Product - Master Category problem

I correct what i write before. In all the languages I have probelms.

I love internet and the power of information... Best Wishes!!

25 Apr 2009, 10:27 PM
#14
jeet_kune_do avatar

jeet_kune_do

Zen Follower

Join Date:
Nov 2008
Location:
Slovenija
Posts:
119
Plugin Contributions:
0

Re: Product - Master Category problem

Jeet Kune Do:

I have 4 languages.
I have a categories, a subcategories and products.
When i click on one subcategory for the Slovene language, i have "no products find" , but for other languages it works.

What could it be?

And when I click to some subcategory it bring me to one different product in different category.

In past I installed Easy populate, but than I did a Full Back Up.

Please Help

Problem resolved with turning off Simple SEO.

I love internet and the power of information... Best Wishes!!