VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Naturt on June 04, 2015, 14:30:16 PM

Title: custom fields in category view!?
Post by: Naturt on June 04, 2015, 14:30:16 PM
Hi there! This is an old and big problem for me. At VM2 this works perfectly, but now (Joomla! 3.4.1 & VirtueMart 3.0.9) many things are changed.

So I have a category, and an unique Category Browse Page at here: components\com_virtuemart\views\category\tmpl\UNIQUEBRPAGE.php

I want to display the products custom fields (titles and values) on this page, but it is not working.

The old and working code (at VM2) was:

if (!empty($product->customfieldsCart)

if the product has custom field

foreach ($product->customfieldsCart as $field)
{
echo $field->custom_title."<br>".$field->custom_field_desc;
}


This is just a short extract from the code. All of my custom variables are gone now. I search all of the forums but I lost..

1. Dumped out the $product variable
(after this:
foreach ($this->products as $product)
)

I see many of arrays, and I reach the most of them, for example the ["virtuemart_product_id"], ["product_name"] etc.
There is an array, named ["customfieldsSorted"].
When I try to dump it
var_dump($product["customfieldsSorted"]); >> Fatal error:  Cannot use object of type TableProducts as array
I tried an other way:
var_dump($product->customfieldsSorted); >> working, so this is an object

There are more arrays and objects in here. I find one of my custom title:
array(1) {
  ["normal"]=>
  array(4) {
    [0]=>
    object(stdClass)#5327 (33) {
      ["virtuemart_custom_id"]=>
      string(3) "108"
      ["custom_parent_id"]=>
      string(1) "0"
      ["virtuemart_vendor_id"]=>
      string(1) "1"
      ["custom_jplugin_id"]=>
      string(1) "0"
      ["custom_element"]=>
      string(1) "0"
      ["admin_only"]=>
      string(1) "0"
      ["custom_title"]=>
      string(21) "[b]MY CUSTOM TITLE[/b]"


My question is, how can I reach it?! It is drive me crazy -.- I want the custom parameters as hell -.-

Title: Re: custom fields in category view!?
Post by: Naturt on June 23, 2015, 16:11:03 PM
Thank you for the nothing. I solved it myself  >:(
Title: Re: custom fields in category view!?
Post by: AH on June 23, 2015, 18:44:45 PM
Well done - and it cost you nothing to learn  :)

Title: Re: custom fields in category view!?
Post by: David Kan on June 24, 2015, 09:52:18 AM
Hi Naturt,

This is an interesting topic.

If you are not very angry, can you please share the solution?

We need to learn from you  8)