News:

Looking for documentation? Take a look on our wiki

Main Menu

Article prices of child products are deleted when changing parent article

Started by pinkeltje77, April 17, 2013, 13:00:35 PM

Previous topic - Next topic

pinkeltje77

I set multiple prices for 3 different shoppergroups in a parent and child article.
This is working fine, however when I change something on the parent article all prices in the child articles are completely deleted.
So when a parent changes I need to fill in all pricing info for the subarticles. Is this a bug?

I really need the prices to stay on changing anything in the parent article. Please help!

jjk

Which VirtueMart 2 version do you use? Do you have the child products set up as 'generic child variant'?
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

pinkeltje77

I use latest version 2.0.20b.

What do you mean by generic child product?

I generated the child product on the parent product bottom. Add child variant.
Then i edited the created product with the right sku, category and pricing details for the shopper groups.

jjk

I'm not shure if your method works without having defined a custom field before using the 'Add child variant' in the 'Product Edit view'.
Normally you would go to 'Products' > 'Custom fields' > Click "New" and enter something similar to this into the form field:


Custom Field Type: Generic child variant
Title: Product Variants (or whatever name you want to display in the frontend product view)
Published: Yes (checked)
Cart Attribute: Yes
Layout Position: ontop (not shure if this is still required. It probably works without specifying this VM template position in the newer versions)

Click on "Save"

After doing the above, add a child product the way you did before or from the product list. Then go to the 'Custom fields' tab in your parent product's 'Product Edit view' and configure the 'Product Variants' (Generic child variant) for example: Display parent as option = Yes, Parent orderable = Yes, Product Alias selected.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

pinkeltje77

Yes did it that way. I have made a custom field type: generic child variant.

Stange thing is though, it works with single prices in the articles.
So if i set a fixed single price (without shoppergroup choice set) it works as intended. And the price on the child products are preserved.

However when I set multiple prices for the various shopper groups they are deleted upon changing the parent article.

jjk

Just tested this. Actually seems to be a bug. I'll report it to the developers.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Milbo

So single prices work as expected storing the product, but not multiprices. Thx
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

pinkeltje77

Thanks, I hope to get a quick solution for this.
My client wants his site up and running and this is a showstopper.

@milbo:
Indeed I tested with single price and then te prices of the child products are preserverd.
When set multiple prices the prices of all the related child products are deleted upon changing the parent article.

pinkeltje77

Please let me now if there is a quick solution coming up?

My site in progress has to go live ...

amerloc

I have the Same problem

Joomla! 2.5.9
VM2 2.0.20b

I am using the stockable plugin. Everytime I modify the main product all the prices I have added to the child products are gone. This is a clients site and it worries me because he has hundreds of products. I am only testing it now but when i do the the product upload to the DB I hope that this will not affect all the products.

Please DEV fix this problem

amerloc

Yeah I have the same problem. When I modify the main product all the child product prices are erased. Is there a fix for this yet? Because this is for a client site and I need to get this fixed or change carts.

amerloc

OK Guys I have found the Damn problem.

VM2 2.0.20b

It is in the product.php file line 1546:

if ( count($old_price_ids) ) {
//delete old unused Customfields
$this->_db->setQuery( 'DELETE FROM `#__virtuemart_product_prices` WHERE `virtuemart_product_price_id` in ("'.implode('","', $old_price_ids ).'") ');
$this->_db->query();
}


This damn code doesn't know if they are old unsued or used. So I have commented it out and now the prices stay. the only problem now is once you add them you can no longer delete the price fields. you can modify them though. So it atleast stops them from being deleted.

$old_price_ids seems to be the root variable that is used to delete the prices. Below is the line that retrieves all the prices for a certain product ID
Line 1486
// Get old IDS
$this->_db->setQuery( 'SELECT `virtuemart_product_price_id` FROM `#__virtuemart_product_prices` WHERE virtuemart_product_id ='.$this->_id );
$old_price_ids = $this->_db->loadResultArray();


Well not sure how to fix this I am still running vmbug to see if I can fix it but for the moment if you comment out ;
if ( count($old_price_ids) ) {
//delete old unused Customfields
$this->_db->setQuery( 'DELETE FROM `#__virtuemart_product_prices` WHERE `virtuemart_product_price_id` in ("'.implode('","', $old_price_ids ).'") ');
$this->_db->query();
}

Then atleast you won't have to worry about your prices disappearing. I would suggest creating a Group called Delete for when I or the DEV find a solution for this

jjk

This issue has been solved already. I just tested it in the latest developer (SVN) version of VM2 and it works.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

amerloc

If this has been fixed can the developers please post the fix here so we can fix this.

Just to clarify, I an using Joomla 2.59 // VM2 2.0.20b and this problem happens with the stockable variant plugin. I not sure about the generic but this one is sure.

I set prices in Child for Public/default then a price for shoppers then a price for Wholesale Group for each variant. Now if I go and modify anything in the Parent then all those prices are erased. I even checked the DB.

Problem with my solution is if you erase the products now the price entries stay in the DB but atleast if you modify the Parent you dont lose your prices.

If there is a solution for this please let us know. My way allows us to set specific prices for each variant to certain groups.

WHy the heck did you guys remove the wholesale price that worked so well  in VM 1. Should have left it and added your new system as a plugin or option.

jjk

You could create a copy of your site and test if the latest developer version 2.0.21c solves your price problem using the stockable plugin (without the stockable plugin prices are not erased in 2.0.21.x when the parent is modified) However, afaik the goal is to remove the stockable plugin and integrate its features into the dynamic child variants - but this still is work in progress and might not be available before version 2.1.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations