Page 1 of 1

Retrieve attributes from products

Posted: 31 Jul 2017, 14:08
by igorpdasilva
Hi, i need to retrieve some attributes weight, height width and length from products(sorry about my bad english rsrs). this informations is for the delivery service.
i have searched about this but not find what i want. i hope someone can help me. im grateful

Re: Retrieve attributes from products

Posted: 01 Aug 2017, 09:59
by aimeos
In the delivery services, you have the basket available including the products to be bought. They contain the product ID (article or selection ID) and the product code (always the article code). Weight/height/length/width are product properties you can retrieve with

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
$search = $manager->createSearch(true);
$search->setConditions( $search->compare( '==', 'product.id', <list of product ids> ) );
$search->setSlice( 0, 0x7fffffff );

foreach( $manager->searchItems( $search, ['product/property'] ) as $productItem ) {
    $propItems = $productItem->getPropertyItems();
}
You can also use this condition if you always need the articles:

Code: Select all

$search->setConditions( $search->compare( '==', 'product.code', <list of product codes> ) );