Related products and filtration customfields by type J3.3.1 VM2.9.8

Started by moonaway, July 10, 2014, 15:08:31 PM

Previous topic - Next topic

moonaway

Hello!

I displayed the related products in the product details page productdetails/default.php and the pop-up window cart/padded.php.
Here's the code for this:

in productdetails/default.php:

<?php
$customFieldsModel 
VmModel::getModel('customfields');
$this->product->customfields $customFieldsModel->getCustomEmbeddedProductCustomFields($this->product->allIds,'R');
$customFieldsModel->displayProductCustomfieldFE($this->product,$this->product->customfields);

echo
'<pre>';
print_r($this->product->customfields);
echo 
'</pre>';

echo 
shopFunctionsF::renderVmSubLayout('relatedProducts',array('product'=>$this->product->customfields));
?>



in cart/padded.php:

<?php
$customFieldsModel 
VmModel::getModel('customfields');
$this->product->customfields $customFieldsModel->getCustomEmbeddedProductCustomFields($this->products[0]->allIds,'R');
$customFieldsModel->displayProductCustomfieldFE($this->products[0],$this->products[0]->customfields);

echo
'<pre>';
print_r($this->product->customfields);
echo 
'</pre>';

echo 
shopFunctionsF::renderVmSubLayout('relatedProducts',array('product'=>$this->product->customfields));
?>



Code is identical, but!


We see in print_r($this->product->customfields) that in file cart/padded.php function getCustomEmbeddedProductCustomFields($this->product->allIds,'R') work is well and we see the array with "R"-type Fields only.
But, in product details page we see the array with all fields without filtration by "R" field type. Why?

Joomla 3.3.1 + Virtuemart 2.9.8
VM3.0.0 testing: http://store.c-site.ru/

Milbo

Hmm there is something more wrong. Our installations with vmbeez5 have not such error. What happens, if you use the fullinstaller?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

moonaway

In default vm-template in productdetails page use this code:
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products'));
But there is a filtration for position. However, if the name of the position is not specified, and the goods are not displayed. This method is not universal.

The code which is used in cart/padded.php is default from default vm-template and it's work well in pop-up window.

Why when I use this code on the productdetails/default.php , it is not working properly?
VM3.0.0 testing: http://store.c-site.ru/

Milbo

Why is this not correctly working for you?

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products'));
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

moonaway

Good question. I want to make a universal solution with filtering by 'R'-type fields type. I saw good code in the file padded.php and decided to check his work elsewhere, but it is not working properly. I want to understand the reason for such work....

for examle:
http://store25.eyemotion.ru/index.php/default-products/default-product-detail - this default vm-template.
In demo customfields there is no specified position by default, and when you add  related products, the output does not work properly. The method used in the padded.php would help avoid this, if everything works in the productdetails page.
VM3.0.0 testing: http://store.c-site.ru/

Milbo

? you dont need it.

Please take a look on the original default.php delivered with vm2.9.8
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

moonaway

http://store25.eyemotion.ru/index.php/default-products/default-product-detail - it's original page defautl.php from fullinstaller 2.9.8, I only wrote headlines and added 2 related product and 2 strings to the product for example.

OK, ask the question differently.
Why function getCustomEmbeddedProductCustomFields($this->product->allIds,'R') used padded.php does not work on the product page?
VM3.0.0 testing: http://store.c-site.ru/

Milbo

I am sorry, I dont get it. You can give an customfield a position. All of them have a position. If you do not enter a position it just uses the fallback to normal respectivly addtocart. and the customfields are resorted for the product display.

also make your live easier using vmdebug('my product',$this->product);
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

moonaway

Sorry for my bad English. I thought that using the function getCustomEmbeddedProductCustomFields I can "filter" array by type field. If it is not, then why this function file paddded.php work?
Maybe I just do not understand how this function works?

And one more question.
It's a situation when we have a parent product and some child products.
We have custom fields in the settings of the parent product. In the settings of child products I want to have other custom fields, but they are rewritten from fields of the parent product by default.
In VM2.6 if we rewrote custom fields manually at a child product, they would save and rewrite custom fields of the parent product. In VM2.9.8 child custom fields aren`t rewritten manually and always remain rewritten parental custom fields.
How to rewrite custom fields at a child product in VM2.9.8?
VM3.0.0 testing: http://store.c-site.ru/

Milbo

You can now override each customfield.

if you see a d: or o: checkbox, then the field is inherited... d is disable, and o is override
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

moonaway

VM3.0.0 testing: http://store.c-site.ru/

moonaway

I found another small bug:

1. In the child plugin the links generated incorrectly:

<select id="7-117customProductData" name="field[7][117][customfield_value]" onchange="window.top.location.href=this.options[this.selectedIndex].value" size="1" class="vm-chzn-select" data-dynamic-update="1" >
   <option value="/index.php?option=com_virtuemart&amp;view=productdetails&amp;virtuemart_category_id=1&amp;virtuemart_product_id=7&amp;Itemid=776" selected="selected">Choose a variant</option>
   <option value="/index.php?option=com_virtuemart&amp;amp;view=productdetails&amp;amp;virtuemart_category_id=1&amp;amp;virtuemart_product_id=7&amp;amp;Itemid=776">Product w/child variant</option>
   <option value="/index.php?option=com_virtuemart&amp;amp;view=productdetails&amp;amp;virtuemart_category_id=1&amp;amp;virtuemart_product_id=8&amp;amp;Itemid=776">child variant 1</option>
   <option value="/index.php?option=com_virtuemart&amp;amp;view=productdetails&amp;amp;virtuemart_category_id=1&amp;amp;virtuemart_product_id=9&amp;amp;Itemid=776">child variant 2</option>
   <option value="/index.php?option=com_virtuemart&amp;amp;view=productdetails&amp;amp;virtuemart_category_id=1&amp;amp;virtuemart_product_id=10&amp;amp;Itemid=776">child variant 3</option>
</select>

2. In the demo data VM2.9.8 positions "related_products" and "related_categories" entered in the wrong field:
VM3.0.0 testing: http://store.c-site.ru/

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/

moonaway

Why?

If the position is not specified, the output of related products is in the position of "normal". Here is an example: http://store25.eyemotion.ru/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1&virtuemart_category_id=1&Itemid=121
VM3.0.0 testing: http://store.c-site.ru/

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/