Properties of selections
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 28
- Joined: 18 Nov 2016, 10:35
Properties of selections
Hi,
I tried to adapt the behaviour of the displayed properties for selections. The idea is to show only the properties of the selected variant as the attributes are done.
Here is the code snipplet of Standard.php of the catalog detail:
And the init section of the partial body-default.php:
With this code $propMap seems to stay empty. Could the $domains array be the problem, there is not product/property domain listed? I tried it with the additional domain 'product/property' with no success. Any suggestions?
Regards
Simon
I tried to adapt the behaviour of the displayed properties for selections. The idea is to show only the properties of the selected variant as the attributes are done.
Here is the code snipplet of Standard.php of the catalog detail:
Code: Select all
...
$context = $this->getContext();
$prodid = $view->param( 'd_prodid' );
$domains = array( 'media', 'price', 'text', 'attribute', 'product' );
$controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
$productItem = $this->getProductItem( $prodid, $domains );
$this->addMetaItems( $productItem, $this->expire, $this->tags );
$productManager = $controller->createManager( 'product' );
$productIds = array_keys( $productItem->getRefItems( 'product' ) );
$products = $this->getDomainItems( $productManager, 'product.id', $productIds, $domains );
$attrIds = array_keys( $productItem->getRefItems( 'attribute' ) );
$mediaIds = array_keys( $productItem->getRefItems( 'media' ) );
$propIds = array_keys( $productItem->getRefItems( 'product/property' ) );
foreach( $products as $product )
{
$attrIds = array_merge( $attrIds, array_keys( $product->getRefItems( 'attribute' ) ) );
$mediaIds = array_merge( $mediaIds, array_keys( $product->getRefItems( 'media' ) ) );
$propIds = array_merge( $propIds, array_keys( $product->getRefItems( 'product/property' ) ) );
}
$attributeManager = $controller->createManager( 'attribute' );
$attributeItems = $this->getDomainItems( $attributeManager, 'attribute.id', $attrIds, $domains );
$this->addMetaItems( $attributeItems, $this->expire, $this->tags );
$mediaManager = $controller->createManager( 'media' );
$mediaItems = $this->getDomainItems( $mediaManager, 'media.id', $mediaIds, $domains );
$this->addMetaItems( $mediaItems, $this->expire, $this->tags );
$propertyManager = $controller->createManager( 'product/property' );
$propertyItems = $this->getDomainItems( $propertyManager, 'product.property.id', $propIds, $domains );
$this->addMetaItems( $propertyItems, $this->expire, $this->tags );
...
Code: Select all
...
$attrMap = $subAttrDeps = array();
$attrItems = $this->get( 'detailAttributeItems', array() );
$propMap = $subPropDeps = array();
$propItems = $this->get( 'detailPropertyItems', array() );
foreach( $this->get( 'detailProductItems', array() ) as $subProdId => $subProduct )
{
$subItems = $subProduct->getRefItems( 'attribute', null, 'default' );
$subItems += $subProduct->getRefItems( 'attribute', null, 'variant' ); // show product variant attributes as well
foreach( $subItems as $attrId => $attrItem )
{
if( isset( $attrItems[ $attrId ] ) )
{
$attrMap[ $attrItem->getType() ][ $attrId ] = $attrItems[ $attrId ];
$subAttrDeps[ $attrId ][] = $subProdId;
}
}
$subItems = $subProduct->getRefItems( 'product/property' );
foreach( $subItems as $propId => $propItem )
{
if( isset( $propItems[ $propId ] ) )
{
$propMap[ $propItem->getType() ][ $propId ] = $propItems[ $propId ];
$subPropDeps[ $propId ][] = $subProdId;
}
}
}
ksort( $attrMap );
ksort( $propMap );
...
Regards
Simon
Re: Properties of selections
You can only retrieve items referenced via the list table using getRefItems(). Therefore, you need the domains.
The product properties are not associated via the list table but directly reference the product in a parent/item relationship. You have to use the product property manager to search for all property items whose parentid is one of the product variants.
The product properties are not associated via the list table but directly reference the product in a parent/item relationship. You have to use the product property manager to search for all property items whose parentid is one of the product variants.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 28
- Joined: 18 Nov 2016, 10:35
Re: Properties of selections
Thx, got it and pushed to the repo