News:

Looking for documentation? Take a look on our wiki

Main Menu

vmError: during child product creation Vm 3.2.2

Started by Miku, May 22, 2017, 07:55:34 AM

Previous topic - Next topic

Miku

Hi,

I can see a bug when trying to create a child product:

vmError: VmTable #__virtuemart_products_en_gb Check not passed. Neither slug nor obligatory value at product_name for auto slug creation is given 0
Child product not created successfully

My setings:
1. 'No Fallback' with the fix from
http://forum.virtuemart.net/index.php?topic=137512.msg481558#msg481558
2. Administrator's language: English ( Polish is default language site)

What I do is:
1. I fill in a translation only for the Polish and save the product  - now it's visible only in Polish according to 'No Fallback' setting - it's OK
2. I try to create a child product  - NOT GOOD  - the error appears.

When Administrator's language is the same as the translation of the product that has been done -  there's no bug.

Joomla! 3.6.5

Milbo

Quote from: Miku on May 22, 2017, 07:55:34 AM

What I do is:
1. I fill in a translation only for the Polish and save the product  - now it's visible only in Polish according to 'No Fallback' setting - it's OK
2. I try to create a child product  - NOT GOOD  - the error appears.
When Administrator's language is the same as the translation of the product that has been done -  there's no bug.
When you change the language, then you cannot see the product in the list. So I wonder how you do that. You must "tricks" it. I mean, you stay in the product, makes sense, but when you would leave the product, you would not be able to edit it in the wrong language and you could not create a child.

Please edit the product model /administrator/components/com_virtuemart/models around line 2257 (function createChild) and add

VmConfig::$vmlang == VmConfig::$defaultLang;
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Miku

Quote from: Milbo on May 22, 2017, 09:58:42 AM
When you change the language, then you cannot see the product in the list. So I wonder how you do that. You must "tricks" it. I mean, you stay in the product, makes sense, but when you would leave the product, you would not be able to edit it in the wrong language and you could not create a child.

Hmm.. Below is a description of 'how to do that'. Maybe that's why, as you called it, I "trick it".

First of all  - Administrator's language (English) is different from the default language site (Polish) - it's because I'm able to learn and look through VM much more easily in searching for any help and so on in English.   
Using "No Fallback" I fill in the translation for the default language site (Polish) and leave empty English if I don't need it.
Doing so, I can see the product in the list for both languages, but when the Administrator's language is English I can't create the child product due to error I've mentioned.

Quote from: Milbo on May 22, 2017, 09:58:42 AM
Please edit the product model /administrator/components/com_virtuemart/models around line 2257 (function createChild) and add

VmConfig::$vmlang == VmConfig::$defaultLang;


I can see the function, but where exactly should I put the code?
public function createChild ($id) {

if(!vmAccess::manager('product.create')){
vmWarn('Insufficient permission to create product');
return false;
}

// created_on , modified_on
$db = JFactory::getDBO ();

$db->setQuery ('SELECT `product_name`,`slug`,`virtuemart_vendor_id` FROM `#__virtuemart_products` JOIN `#__virtuemart_products_' . VmConfig::$vmlang . '` as l using (`virtuemart_product_id`) WHERE `virtuemart_product_id`=' . (int)$id);
$parent = $db->loadObject ();
$prodTable = $this->getTable ('products');

$childs = $this->getProductChildIds ($id);

if($childs){
$lastCId = end($childs);
reset($childs);
if(!empty($lastCId)){
$db->setQuery ('SELECT `product_name`,`slug`,`virtuemart_vendor_id` FROM `#__virtuemart_products` JOIN `#__virtuemart_products_' . VmConfig::$vmlang . '` as l using (`virtuemart_product_id`) WHERE `virtuemart_product_id`=' . (int)$lastCId);
$lastChild = $db->loadObject ();
if(!empty($lastChild->slug)){
$prodTable->slug = $lastChild->slug;
}
}
} else if(empty($parent->slug)){
$prodTable->slug = $parent->product_name;
} else {
$prodTable->slug = $parent->slug;
}

$prodTable->checkCreateUnique('#__virtuemart_products_' . VmConfig::$vmlang,'slug');
//$newslug = $prodTable->checkCreateUnique('products_' . VmConfig::$vmlang,$parent->slug);
$data = array('product_name' => $parent->product_name, 'slug' => $prodTable->slug, 'virtuemart_vendor_id' => (int)$prodTable->virtuemart_vendor_id, 'product_parent_id' => (int)$id);

$prodTable = $this->getTable ('products');
$prodTable->bindChecknStore ($data);

return $data['virtuemart_product_id'];
}


Milbo

just on top, for example behind the $db = JFactory::getDbo(), so you have only one shop language?

Btw, using the backend in english for easier communication with others is very common :-)
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Miku

Quote from: Milbo on May 22, 2017, 11:55:31 AM
just on top, for example behind the $db = JFactory::getDbo()
No effect. The error still exists.
Quote from: Milbo on May 22, 2017, 11:55:31 AM
so you have only one shop language?
No, I have multilanguage shop but I have some products I don't want to be shown in the second language. That's why I use "No Fallback."

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Miku

#6
I'll do my best to be clear as possible. So

VM backend settings:
- multilanguage shop (2 languages)
- 'No Fallback' actived with the fix from http://forum.virtuemart.net/index.php?topic=137512.msg481558#msg481558
How I see it - 'No Fallback' prevents one-language translated products from being visible on the "other" language(s) available on the website, contrary to 'Dual Fallback' which enables those 'one-language translated products' to be visible in all other languages, assigning them "user-dependant" data from the primary translation.

Steps:
- you create a product with just one translation -  in the language that is different from the backend language, so, at first you choose an appropriate language from vm-lang-list-container and then save the product.
- you try to create a child for that product - the error appears.

Milbo

Quote from: Miku on May 22, 2017, 14:44:16 PM

Steps:
- you create a product with just one translation -  in the language that is different from the backend language, so, at first you choose an appropriate language from vm-lang-list-container and then save the product.

Ahh, there is the problem, ...
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/