Pulling product information in templates

Questions around the Aimeos bundle for the Symfony framework
Forum rules
Always add your Symfony, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
alex110504
Posts: 4
Joined: 15 Jan 2017, 04:28

Pulling product information in templates

Post by alex110504 » 16 Feb 2017, 07:22

I am having trouble with $productItem->getRefItems( 'text', 'short', 'default' ) function, as it returns empty array. I have the demo product database installed, and have short and long text associated with the Demo article out of the box, however cannot see not only the short text in the catalog/lists component, but the product price either. I am talking about template in ext/ai-client-html/client/html/templates/catalog/lists/items-body-default.php.
There is a foreach loop in items-body-default.php starting around line 122:
<?php foreach( $productItem->getRefItems( 'text', 'short', 'default' ) as $textItem ) : ?>
<div class="text-item" itemprop="description">
<?php echo $enc->html( $textItem->getContent(), $enc::TRUST ); ?><br/>
</div>
<?php endforeach; ?>
which gets skipped because $productItem->getRefItems( 'text', 'short', 'default' ) returns empty array.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: Pulling product information in templates

Post by aimeos » 16 Feb 2017, 08:13

Where does the product items come from? Did you search for them yourself via

Code: Select all

$productManager->searchItems( $criteria );
If yes, you have to add the domains you want to fetch too:

Code: Select all

$productManager->searchItems( $criteria, array( 'text', 'price' ) );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

alex110504
Posts: 4
Joined: 15 Jan 2017, 04:28

Re: Pulling product information in templates

Post by alex110504 » 20 Feb 2017, 19:57

Turns out, I had not set the language for the site. All text items and prices were set for English. Setting language to 'all' on the text and price items made them show.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: Pulling product information in templates

Post by aimeos » 21 Feb 2017, 09:33

A much better way is to set the default locale in the Symfony config.yml:

Code: Select all

# app/config/config.yml
framework:
    default_locale: fr
Then, you can still use more languages in the future.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply