Images attributes aimeos 2018.1

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Images attributes aimeos 2018.1

Post by Travin » 06 Feb 2018, 12:52

Hey guys
At my 2017.10 I had the code \client\html\templates\catalog\detail\image-partial-bottom.php:

Code: Select all

$getVariantData = function( $mediaId, array $mediaItems ) use ( $enc )
{
	$string = '';

	if( isset( $mediaItems[$mediaId] ) )
	{
		foreach( $mediaItems[$mediaId]->getRefItems( 'attribute', null, 'variant' ) as $id => $item ) {
			$string .= ' data-variant-' . $item->getType() . '="' . $enc->attr( $id ) . '"';
		}
	}

	return $string;
};
I just switched ->getRefItems( 'attribute', null, 'variant' ) to ->getRefItems( 'attribute', null, 'default' ). And it's worked at 2017.10, i recieved images attributes. Now at 2018 I can't recieve images attributes http://joxi.ru/ZrJepXyU17YpxA

According to axplanation of public function getRefItems ( $domain = null, $type = null, $listtype = null, $active = true )
* @param string|null $domain Name of the domain (e.g. product, text, etc.) or null for all
* @param array|string|null $type Name/Names of the item type or null for all
* @param array|string|null $listtype Name/Names of the list item type or null for all
* @param boolean $active True to return only active items, false to return all
* @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
I tried $mediaItems[$mediaId]->getRefItems( null, null, null, false )
Nothing. Can't access to image data
At my mshop_product_list I have a row
http://joxi.ru/Dr83N6EukbQNJA
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

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

Re: Images attributes aimeos 2018.1

Post by aimeos » 07 Feb 2018, 11:08

In 2018.01 it's much easier than before because attributes and properties of media items are available bei default, e.g.:

Code: Select all

foreach( $product->getListItem( 'media' ) as $listItem ) {
    $config = $listItem->getConfig();
    if( ( $refItem = $listItem->getRefItem() ) !== null ) {
        $mediaAttributes = $refItem->getRefItems( 'attribute' );
        $mediaProperties = $refItem->getPropertyItems();
    }
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Images attributes aimeos 2018.1

Post by Travin » 08 Feb 2018, 10:45

much easier, cool :)
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

Post Reply