VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Development & Testing => Topic started by: moonaway on July 10, 2014, 15:08:31 PM

Title: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 10, 2014, 15:08:31 PM
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
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 10, 2014, 19:08:15 PM
Hmm there is something more wrong. Our installations with vmbeez5 have not such error. What happens, if you use the fullinstaller?
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 10, 2014, 19:49:15 PM
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?
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 10, 2014, 20:12:16 PM
Why is this not correctly working for you?

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products'));
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 10, 2014, 21:02:18 PM
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 (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.
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 10, 2014, 21:35:02 PM
? you dont need it.

Please take a look on the original default.php delivered with vm2.9.8
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 11, 2014, 08:41:35 AM
http://store25.eyemotion.ru/index.php/default-products/default-product-detail (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?
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 11, 2014, 10:28:16 AM
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);
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 11, 2014, 20:27:58 PM
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?
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 11, 2014, 21:31:24 PM
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
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 11, 2014, 23:09:56 PM
Thanks for the answer on second question!
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 12, 2014, 12:46:58 PM
I found another small bug:

1. In the child plugin the links generated incorrectly:
(http://i058.radikal.ru/1407/b2/e325d9bce3d2.png)
<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:
(http://s019.radikal.ru/i623/1407/c9/8d43c2694b19.png)
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 15, 2014, 02:02:04 AM
hm? no they dont need a position,
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: moonaway on July 19, 2014, 09:43:28 AM
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 (http://store25.eyemotion.ru/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=1&virtuemart_category_id=1&Itemid=121)
Title: Re: Related products and filtration customfields by type J3.3.1 VM2.9.8
Post by: Milbo on July 21, 2014, 13:12:34 PM
Please lets talk here about that http://forum.virtuemart.net/index.php?topic=124360.msg427370#msg427370