- Posts: 43
- Thank you received: 0
Problems with variants
12 years 3 months ago #159812
by DavidThor
Problems with variants was created by DavidThor
-- url of the page with the problem -- :
nordic-medical.de/index.php/catalogue/pr...-stille-eye-scissors
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.3.1
-- PHP version -- : x.x.x
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message
I've created a product wtih different characteristics (e.g. nordic-medical.de/index.php/catalogue/pr...-stille-eye-scissors ) and everything looks as it should. If I then go back to the product and make modification to e.g. the description or FaLang translation and click save ... the characteristics get all messed up or are reset to a default value. There's even a disconnect between characteristics specified on the front end and the characteristics specified in the back end.
Any idea why this is happening and how it can be resolved?
Thanks,
David
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.3.1
-- PHP version -- : x.x.x
-- Browser(s) name and version -- : XXXXX x.x.x
-- Error-message(debug-mod must be tuned on) -- : Error_message
I've created a product wtih different characteristics (e.g. nordic-medical.de/index.php/catalogue/pr...-stille-eye-scissors ) and everything looks as it should. If I then go back to the product and make modification to e.g. the description or FaLang translation and click save ... the characteristics get all messed up or are reset to a default value. There's even a disconnect between characteristics specified on the front end and the characteristics specified in the back end.
Any idea why this is happening and how it can be resolved?
Thanks,
David
Please Log in or Create an account to join the conversation.
12 years 3 months ago #159818
by nicolas
Replied by nicolas on topic Problems with variants
Hi,
I guess that the issue is that the product code of the variants got changed and thus when the system tries to managed the variants when you save the product, it tries to recreate them and mess them up.
An easy way to circumvent the problem is to turn off the "Generate variants automatically" option of the configuration. That way, the variants won't be generated or regenerated automatically and that will avoid that kind of problem.
And since you edit each variant to change the product code (and potentially other info) anyway you won't loose time creating them manually when needed with the "new" button of the variants listing.
I guess that the issue is that the product code of the variants got changed and thus when the system tries to managed the variants when you save the product, it tries to recreate them and mess them up.
An easy way to circumvent the problem is to turn off the "Generate variants automatically" option of the configuration. That way, the variants won't be generated or regenerated automatically and that will avoid that kind of problem.
And since you edit each variant to change the product code (and potentially other info) anyway you won't loose time creating them manually when needed with the "new" button of the variants listing.
Please Log in or Create an account to join the conversation.
12 years 3 months ago #159868
by DavidThor
Replied by DavidThor on topic Problems with variants
Hi,
I already had 'Generate variants automatically' turned off. I changed it back to on ... same problem. I then changed it back to off ... still same problem.
I already had 'Generate variants automatically' turned off. I changed it back to on ... same problem. I then changed it back to off ... still same problem.
Please Log in or Create an account to join the conversation.
12 years 3 months ago #159909
by DavidThor
Replied by DavidThor on topic Problems with variants
Any other ideas?
Please Log in or Create an account to join the conversation.
12 years 3 months ago #159930
by nicolas
Replied by nicolas on topic Problems with variants
With the option turned off, the system shouldn't alter the variants at all so I don't see how that's possible that you get that result.
I guess we'll need that you provide a backend and FTP access via our contact form in order to analyze the problem as we can't reproduce it. Please also include a link to this thread.
www.hikashop.com/contact-us.html
I guess we'll need that you provide a backend and FTP access via our contact form in order to analyze the problem as we can't reproduce it. Please also include a link to this thread.
www.hikashop.com/contact-us.html
Please Log in or Create an account to join the conversation.
12 years 3 months ago #160049
by DavidThor
Replied by DavidThor on topic Problems with variants
Backend and FTP access emailed. //David
Please Log in or Create an account to join the conversation.
12 years 3 months ago - 12 years 3 months ago #160162
by nicolas
Replied by nicolas on topic Problems with variants
Hi,
I was not able to log on your FTP server but I think I found the problem.
change the code:
to:
in the file administrator/components/com_hikashop/classes/product.php and that should fix the problem.
Let me know how it goes.
I was not able to log on your FTP server but I think I found the problem.
change the code:
Code:
$results = $this->database->loadObjectList();
if(!empty($results)){
foreach($results as $variant){
foreach($element->characteristics as $char){
$char_ids = array();
foreach($char->values as $k => $val){
$char_ids[]=$k;
}
if(!in_array($variant->variant_characteristic_id,$char_ids)){
$this->database->setQuery('INSERT IGNORE INTO '.hikashop_table('variant').' (variant_characteristic_id,variant_product_id,ordering) VALUES ('.$char->default_id.','.$variant->variant_product_id.',0);');
$this->database->query();
}
}
}
}
Code:
$links = $this->database->loadObjectList();
if(!empty($results)){
//for each variant, and for ech characteristic, if the link is missing between both, add one between the variant and the default value of the characteristic
foreach($results as $variant){
foreach($links as $link){
if($link->variant_product_id==$results->product_id){
foreach($element->characteristics as $char){
$found = false;
foreach($char->values as $k => $val){
if($k==$link->variant_characteristic_id){
$found = true;
}
}
if(!$found){
$this->database->setQuery('INSERT IGNORE INTO '.hikashop_table('variant').' (variant_characteristic_id,variant_product_id,ordering) VALUES ('.$char->default_id.','.$link->variant_product_id.',0);');
$this->database->query();
}
}
}
}
}
}
Let me know how it goes.
Last edit: 12 years 3 months ago by nicolas. Reason: fixing typo in the code
The following user(s) said Thank You: DavidThor
Please Log in or Create an account to join the conversation.
12 years 3 months ago #160348
by DavidThor
Replied by DavidThor on topic Problems with variants
Thank you so much ... that did the trick ... //Davi
Please Log in or Create an account to join the conversation.
Time to create page: 0.212 seconds