Page 1 of 1

Pulling product information in templates

Posted: 16 Feb 2017, 07:22
by alex110504
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.

Re: Pulling product information in templates

Posted: 16 Feb 2017, 08:13
by aimeos
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' ) );

Re: Pulling product information in templates

Posted: 20 Feb 2017, 19:57
by alex110504
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.

Re: Pulling product information in templates

Posted: 21 Feb 2017, 09:33
by aimeos
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.