Author Topic: vmError: during child product creation Vm 3.2.2  (Read 2050 times)

Miku

  • Jr. Member
  • **
  • Posts: 79
  • A beginner
  • VirtueMart Version: 3.0.18, J!3.6.4
vmError: during child product creation Vm 3.2.2
« on: May 22, 2017, 07:55:34 am »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10087
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: vmError: during child product creation Vm 3.2.2
« Reply #1 on: May 22, 2017, 09:58:42 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
Code: [Select]
VmConfig::$vmlang == VmConfig::$defaultLang;
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Miku

  • Jr. Member
  • **
  • Posts: 79
  • A beginner
  • VirtueMart Version: 3.0.18, J!3.6.4
Re: vmError: during child product creation Vm 3.2.2
« Reply #2 on: May 22, 2017, 11:32:56 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.

Please edit the product model /administrator/components/com_virtuemart/models around line 2257 (function createChild) and add
Code: [Select]
VmConfig::$vmlang == VmConfig::$defaultLang;

I can see the function, but where exactly should I put the code?
Code: [Select]
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10087
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: vmError: during child product creation Vm 3.2.2
« Reply #3 on: May 22, 2017, 11:55:31 am »
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 :-)
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Miku

  • Jr. Member
  • **
  • Posts: 79
  • A beginner
  • VirtueMart Version: 3.0.18, J!3.6.4
Re: vmError: during child product creation Vm 3.2.2
« Reply #4 on: May 22, 2017, 12:52:00 pm »
just on top, for example behind the $db = JFactory::getDbo()
No effect. The error still exists.
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10087
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: vmError: during child product creation Vm 3.2.2
« Reply #5 on: May 22, 2017, 13:11:52 pm »
I cant reproduce it ...
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Miku

  • Jr. Member
  • **
  • Posts: 79
  • A beginner
  • VirtueMart Version: 3.0.18, J!3.6.4
Re: vmError: during child product creation Vm 3.2.2
« Reply #6 on: May 22, 2017, 14:44:16 pm »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10087
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: vmError: during child product creation Vm 3.2.2
« Reply #7 on: May 22, 2017, 16:03:58 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, ...
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/