No value and title in getattributes

Hi,
this is my first project with oxid and I need some help. I use the Community Edition 4.5.4_39463.

I changed the inc/product.tpl and want to display the attributes of the product in a table. I was trying to get the title and value but no result.
The code I use is as follows

      [{foreach from=$oView->getAttributes() item=oAttr name=attribute}]
			[{$product->oxarticles__oxtitle->value}]
			title1: [{$oAttr->title}]
			value1: [{$oAttr->value}]<br />
      [{/foreach}]

      [{foreach from=$product->getAttributes() item=oAttr name=attribute}]
			[{$product->oxarticles__oxtitle->value}]
			title: [{$oAttr->title}]
			value: [{$oAttr->value}]<br />
      [{/foreach}]

In both cases he obviously knows that the product has 4 attributes, because he writes me the oxarticle__oxtitle four times, but he has no title and value of the attributes, not from oView and not from product.
I also checke the DB, and found the Attributes stored with a value_1 in the oxobject2attributes and a title and title1 in the oxattributes table.
What I’m doing wrong? Could someone please give me a hint!

Hello, is there nobody who can help me. (after one day with no answer)

Or is there an easier way to have a list-view of all products in a category with only one line for each produkt with a short title, the attributes, price and a combobox for the variants and the basket-button at the end.
Please help!
Thanks
Martin

Sorry, I have no idea :frowning:

Hi Hanne,
okay.

Anybody else, who does have any idea, what I need to look for?


      [{foreach from=$product->getAttributes() item=oAttr name=attribute}]
			[{$product->oxarticles__oxtitle->value}]
			title: [{$oAttr->oxattribute__oxtitle->value}]
			value: [{$oAttr->oxattribute__oxvalue->value}]<br />
      [{/foreach}]

Hallo Frank,

thanks a lot, this works perfect.

Could you please tell me for my understanding, why the code I used works in the details.tpl, where I copied it from and I need to ask for oxattributes__oxtitle.

Where can I find such data, or the structure of the variables? Is there any documentation?
This would help me to solve my upcoming problems faster and without the need of others time.

Thanks
Martin

Best document is the source code. Every page has a controller in “views”, and a template in “out/template name/tpl”, which is defined by the “render” method of the controller. The controller class is available in the template as “$oView”. Every controller is derived from oxUBase, which is derived from oxView.

So whenever you see something like “$oView->someMethod()” in a template, you can find this method in the controller class, oxUBase or oxView. In the case of “$oView->getAttributes()” you’ll find it in details.php, which is the correspondent controller for details.tpl. This means it will only work in details.tpl, because other templates have other controllers.

Now if you look at this function in details.php, you see that it calls $product->getAttributes(), and then rewrites the properties of the attribute into a new object (for compatibility reasons). You can also see the original properties of the attributes returned by $product->getAttributes() there (oxattribute__oxtitle->value).

Hi Frank,

Thank you very much for the explanation. This will help me for my future work with oxid.

Thanks for your help.
Martin