Skip to main content

Export Attributes

The bundle offers a service to format the attributes and attribute values into the necessary format for the twocream Shopware Connector Bundle.

The service must be obtained via dependency injection; it is important that the Asset Helper for the project implements the interface Twocream\ProductAttributeBundle\Components\Export\Helper\AssetHelperInterface.

Product Attribute Service

Class

Twocream\ProductAttributeBundle\Components\Export\Service\ProductAttributeService

Method prepareAttribute

This method formats an attribute object into an array.

NameValue
FunctionprepareAttribute(Concrete $attribute): ?array
Argument $attributeAttribute object that should be formatted
Return valueArray with attribute data under the following keys:
'id', 'uuid', 'identifier', 'quantity-value-default', 'show-on-filter', 'show-on-detail', 'attribute-type', 'sort-type', 'position', 'attribute-name', 'attribute-description', 'attribute-locations'

Method prepareAttributeValue

This method formats an attribute value object into an array.

NameValue
FunctionprepareAttributeValue(Concrete $attributeValue, AssetHelperInterface $assetHelper, array $valueThumbnails, bool $exportArticleAssignment, string $articleNumberField): ?array
Argument $attributeValueAttribute value object that should be formatted
Argument $assetHelperAsset helper for copying assets, which implements the Asset Helper interface
See Asset Helper Interface
(Optional) Argument $valueThumbnailsArray of thumbnails to be generated
(Optional) Argument $exportArticleAssignmentIf true, the return array includes 'article-assignments' with the IDs of the linked objects; default is true
(Optional) Argument $articleNumberFieldName of the ID field in the product class used for article links, default is 'articleNumber'
Return valueArray with attribute value data under the following keys:
'id', 'uuid', 'identifier', 'attribute-id', 'attribute-uuid', 'quantity-value', 'position', 'value', 'color', 'image'

Method getArticleAssignmentByProductId

This method returns the IDs and UUIDs of all attribute values that have a link to a specific data object.

NameValue
FunctiongetArticleAssignmentByProductId(DataObject\Listing\Concrete $listing, int $productId): array
Argument $listingListing of the attribute value class
Argument $productIdID of the object for which the function should find the linked attribute values
Return valueArray with the IDs and UUIDs of the linked attribute values; each array entry follows this format:
['id' => 123, 'uuid' => 123]

Asset Helper Interface

Twocream\ProductAttributeBundle\Components\Export\Helper\AssetHelperInterface

This method serves to export the images of the attribute values. Within the twocream Shopware Connector Bundle, there is an abstract logic that handles the storage of these images. It is important that this interface is implemented in the project-specific Asset Helper.