Product gettitle etc

Hi,

In the basket:

[{foreach from=$oxcmp_basket->getContents() name=miniBasketList item=_product}]

i can use:

[{ $_product->gettitle() }]

to get the products name, color and size. but how can i get only one of them?

[U][B]Solution:[/B][/U]

[QUOTE=KaiNeuwerth;125237]


[{assign var="oSingleProduct" value=$_product->getArticle()}]
<!-- Now you have an oxArticle object saved in $oSingleProduct! $_product is only an oxBasketItem object. -->
[{$oSingleProduct->oxarticles__oxtitle->value}] <!-- this should work now... -->

[/QUOTE]

@KaiNeuwerth : [{$oSingleProduct->oxarticles__oxvarselect->value}] … <-- this gave me the Color/size which is in Variants/selections of the product.

Thanks a lot!

any suggestions would be nice.

some patience would be nice

edit:it think its enough patience now, here a possible solution:


you will need to replace “basketContents” with “miniBasketList” in the code cause that is the name of the foreach loop

[QUOTE=vanilla thunder;124910]some patience would be nice

edit:it think its enough patience now, here a possible solution:

you will need to replace “basketContents” with “miniBasketList” in the code cause that is the name of the foreach loop[/QUOTE]

^+1 Had to laugh :smiley:

nice one - maybe we put that into the wiki? :slight_smile:

What about putting the basket contents in an own variable and accessing single products by their array index?

Example:


[{assign var="aBasketContents" value=$oxcmp_basket->getContents()}]
[{$aBasketContents[1]->getTitle()}]

Thanks for the detailed help :slight_smile:
How can i then get “products name, color and size” ?
also, nothing happens when i type:

[{$_product}]

and this within the other foreach…:

[{foreach key=key item=item from=$_product}]
[{$key}]: [{$item}]<br />
[{/foreach}]

etc. tryed many different ways, but i couldnt get it to extract any good info, like the 3 mentioned above.

getTitle() = “T-Shirt med U-hals, Black | S”. Only need them separately

Edit: its in basketFlyout. if that makes any difference.

in the “normal” basket there is an array of basket articles and they are accessed by their index, (at least in the actual version) but i have not checked if it would work in minibasket, too.

[{foreach key=key item=item from=$_product}]

you should not use a foreach loop on a single element, cause it only works with arrays or lists.
try:

[{foreach key=key item=item from=$oxcmp_basket->getContents() }]

in the “normal” basket there is an array of basket articles and they are accessed by their index, (at least in the actual version) but i have not checked if it would work in minibasket, too.
this is how the minibasket.tpl look like:
minibasket.tpl - Pastebin.com

[{foreach key=key item=item from=$oxcmp_basket->getContents() }]

I tryed that and it didnt work.

Has no one tryed or has any knowledge on how to get something like the size of a product? :smiley:

edit: and why did the mods remove my german threat? i like having better odds…

I guess we’ve all already did that but in an other way as you like to do.
It’s hard for me to understand what you’d like to reach…

Normally the basket contents are just iterated in a foreach loop. In each loop cycle you have 1 oxArticle-Object (or maybe oxBasketItem, idk) in your variable $item so you can do things like


[{$item->oxarticles__oxtitle->value}] <-- echos the title of a product
[{assign var="oPrice" value=$item->getPrice()}] <-- returns an oxPrice-Object with filled properties
[{assign var="oManufacturer" value=$item->getManufacturer()}] <-- returns an oxManufacturer-Object

and so on… Please make us an understandable example of what you have and what you’d like to have instead!

Hi Kai and thanks for the responds.

Hope this pictures describes what i want, else let me know, and i will do better to explain it :slight_smile:

Allright then try to add the following code over your te[{ … }]st…


[{assign var="oSingleProduct" value=$_product->getArticle()}]
<!-- Now you have an oxArticle object saved in $oSingleProduct! $_product is only an oxBasketItem object. -->
[{$oSingleProduct->oxarticles__oxtitle->value}] <!-- this should work now... -->

That is exacly what i needed :slight_smile:
Is there a way to know, what exacly i get retrieve/extract from $oSingleProduct? So i know exacly what things(like oxarticles__oxtitle->value) i can use on it?
I would like to be able to quickly know, how i can get information from each product. Like if i wanted the *Size and color(variant), the Manufacturer, height, Weight,Quantity etc. which you set in the oxid backend. how do you do that fast?
To get the color and size in my example, i probably would have to do some trimming?

Edit: solution added to OP.

you could add

[{debug}]

inside a template, clear /tmp and then call the site in frontend - it will open a popup with tons of information about what values you can access within the template

Another solution would be:

[{$oSingleProduct|dumpVar}]

With it you get the most information about the oxArticle object but I don’t know whether it helps you or not :smiley:

[QUOTE=Hebsacker;125268]you could add

[{debug}]

inside a template, clear /tmp and then call the site in frontend - it will open a popup with tons of information about what values you can access within the template[/QUOTE]

It didnt get oxarticles__oxtitle etc. when i tryed it.

[QUOTE=KaiNeuwerth;125269]Another solution would be:

[{$oSingleProduct|dumpVar}]

With it you get the most information about the oxArticle object but I don’t know whether it helps you or not :D[/QUOTE]

'oxarticles__oxtitle' => 
  oxField::__set_state(array(
     'value' => 'T-Shirt med V-hals',

Great :slight_smile: but the list doesnt contain “Black”(color and size from the picture above…Black | S)

What you want is oxarticles__oxvarselect…

But that isnt shown in the dumpVar. So:

How do i get to find the information i want in the future? how did you find oxarticles__oxvarselect? i would like to have help on how i can help myself :slight_smile:

edit: [{$oSingleProduct->oxarticles__oxvarselect->value}] worked perfectly. thanks :slight_smile: OP updated.

[QUOTE=gnomic;125279]But that isnt shown in the dumpVar.[/QUOTE]
Right, because the oxArticle object gets extended to the runtime when fields are needed (uses lazyload).

[QUOTE=gnomic;125279]
How do i get to find the information i want in the future? how did you find oxarticles__oxvarselect?[/QUOTE]
Simple: Because I know it :slight_smile:
Let me explain you why it’s called “oxarticles__oxvarselect”…
The first thing you can see here is “oxarticles” (this is the database table oxarticles).
Then comes the seperator “__” which means: Now comes the field I want to access.
In oxarticles there is a field “oxvarselect”.
I hope this helps you to understand how to select fields out of the database.