How to configure and adapt Aimeos based shops as developer
Forum rules: Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#2244 by swpierce
15 Dec 2015, 18:50
I have an attribute with code 'attr-code1'
I have a media entry defined and associated with that attribute. Everything in the admin panel looks fine. If I open that attribute and click on the media tab, I see the media. In the database, the appropriate stuff is in mshop_attribute_list, etc.

I try to load the referenced media in my code like this (might not be most efficient?):
Code: Select all                        $attributeManager = MShop_Factory::createManager( $context, 'attribute' );
                        $search = $attributeManager->createSearch( true );
                        $expr = array(
                            $search->getConditions(),
                            $search->compare( '==', 'attribute.code', 'attr-code1' ),
                        );
                        $search->setConditions( $search->combine( '&&', $expr ) );
                        $search->setSortations( array( $search->sort( '-', 'attribute.id' ) ) );
                       
                        $dlAttrList = $attributeManager->searchItems( $search );
                        $downloadAttribute = reset( $dlAttrList );

                        foreach( $downloadAttribute->getListItems( 'media', 'default' ) as $media )
                        {
                            // do stuff
                        }


The attribute loads just fine. The call get getListItems( 'media', 'default' ) returns an empty list. I also tried getListItems( 'media' ) and getListItems() - all return an empty list.

What am I doing wrong?
#2247 by aimeos
16 Dec 2015, 09:56
swpierce wrote:
Code: Select all                        $dlAttrList = $attributeManager->searchItems( $search );



You have to tell the manager that it should load the referenced attributes to:
Code: Select all$attributeManager->searchItems( $search, array( 'attribute' ) );