diff --git a/src/Export/Adapters/AbstractSalesFrequencyAdapter.php b/src/Export/Adapters/AbstractSalesFrequencyAdapter.php index 6a54c35..c8c2998 100644 --- a/src/Export/Adapters/AbstractSalesFrequencyAdapter.php +++ b/src/Export/Adapters/AbstractSalesFrequencyAdapter.php @@ -7,7 +7,7 @@ use FINDOLOGIC\Export\Data\SalesFrequency; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -abstract class AbstractSalesFrequencyAdapter +abstract class AbstractSalesFrequencyAdapter implements AdapterInterface { public function adapt(ProductEntity $product): ?SalesFrequency { diff --git a/src/Export/Adapters/AdapterFactory.php b/src/Export/Adapters/AdapterFactory.php index 78ecda6..81c53f8 100644 --- a/src/Export/Adapters/AdapterFactory.php +++ b/src/Export/Adapters/AdapterFactory.php @@ -22,6 +22,8 @@ class AdapterFactory private NameAdapter $nameAdapter; + private OptionsAdapter $optionsAdapter; + private OrderNumberAdapter $orderNumberAdapter; private PriceAdapter $priceAdapter; @@ -38,6 +40,8 @@ class AdapterFactory private UserGroupsAdapter $userGroupsAdapter; + private VariantConfigurationAdapter $variantConfigurationAdapter; + public function __construct( AttributeAdapter $attributeAdapter, BonusAdapter $bonusAdapter, @@ -47,6 +51,7 @@ public function __construct( ImagesAdapter $imagesAdapter, KeywordsAdapter $keywordsAdapter, NameAdapter $itemNameAdapter, + OptionsAdapter $optionsAdapter, OrderNumberAdapter $orderNumberAdapter, PriceAdapter $priceAdapter, AbstractSalesFrequencyAdapter $salesFrequencyAdapter, @@ -54,7 +59,8 @@ public function __construct( SummaryAdapter $summaryAdapter, ShopwarePropertiesAdapter $shopwarePropertiesAdapter, UrlAdapter $urlAdapter, - UserGroupsAdapter $userGroupsAdapter + UserGroupsAdapter $userGroupsAdapter, + VariantConfigurationAdapter $variantConfigurationAdapter ) { $this->attributeAdapter = $attributeAdapter; $this->bonusAdapter = $bonusAdapter; @@ -64,6 +70,7 @@ public function __construct( $this->imagesAdapter = $imagesAdapter; $this->keywordsAdapter = $keywordsAdapter; $this->nameAdapter = $itemNameAdapter; + $this->optionsAdapter = $optionsAdapter; $this->orderNumberAdapter = $orderNumberAdapter; $this->priceAdapter = $priceAdapter; $this->salesFrequencyAdapter = $salesFrequencyAdapter; @@ -72,6 +79,7 @@ public function __construct( $this->shopwarePropertiesAdapter = $shopwarePropertiesAdapter; $this->urlAdapter = $urlAdapter; $this->userGroupsAdapter = $userGroupsAdapter; + $this->variantConfigurationAdapter = $variantConfigurationAdapter; } public function getAttributeAdapter(): AttributeAdapter @@ -114,6 +122,11 @@ public function getNameAdapter(): NameAdapter return $this->nameAdapter; } + public function getOptionsAdapter(): OptionsAdapter + { + return $this->optionsAdapter; + } + public function getOrderNumbersAdapter(): OrderNumberAdapter { return $this->orderNumberAdapter; @@ -153,4 +166,9 @@ public function getUserGroupsAdapter(): UserGroupsAdapter { return $this->userGroupsAdapter; } + + public function getVariantConfigurationAdapter(): VariantConfigurationAdapter + { + return $this->variantConfigurationAdapter; + } } diff --git a/src/Export/Adapters/AdapterInterface.php b/src/Export/Adapters/AdapterInterface.php new file mode 100644 index 0000000..9147bd1 --- /dev/null +++ b/src/Export/Adapters/AdapterInterface.php @@ -0,0 +1,12 @@ +properties || !$product->properties->count()) { - return []; - } - - return $this->getPropertyGroupOptionAttributes($product->properties); - } - - /** + * @deprecated tag:6.0.0 - Logic was moved to the OptionsAdapter * @return Attribute[] */ protected function getOptionAttributes(ProductEntity $product): array { - if (!$product->options || !$product->options->count()) { - return []; - } - - return $this->getPropertyGroupOptionAttributes($product->options); + return []; } /** * @return Attribute[] */ - protected function getPropertyGroupOptionAttributes(PropertyGroupOptionCollection $collection): array - { - $attributes = []; - - foreach ($collection as $propertyGroupOptionEntity) { - $group = $propertyGroupOptionEntity->group; - if ($group && !$group->filterable) { - continue; - } - - $attributes = array_merge($attributes, $this->getAttributePropertyAsAttribute($propertyGroupOptionEntity)); - } - - return $attributes; - } - - /** - * @return Attribute[] - */ - protected function getAttributePropertyAsAttribute(PropertyGroupOptionEntity $propertyGroupOptionEntity): array + protected function getPropertyAttributes(ProductEntity $product): array { - $attributes = []; - - $group = $propertyGroupOptionEntity->group; - if ($group && $propertyGroupOptionEntity->getTranslation('name') && $group->getTranslation('name')) { - $groupName = $this->getAttributeKey($group->getTranslation('name')); - $propertyGroupOptionName = $propertyGroupOptionEntity->getTranslation('name'); - if (!Utils::isEmpty($groupName) && !Utils::isEmpty($propertyGroupOptionName)) { - $propertyGroupAttrib = new Attribute($groupName); - $propertyGroupAttrib->addValue(Utils::removeControlCharacters($propertyGroupOptionName)); - - $attributes[] = $propertyGroupAttrib; - } + if (!$product->properties || !$product->properties->count()) { + return []; } - return $attributes; + return $this->getPropertyGroupOptionAttributes($product->properties); } protected function getCustomFieldAttributes(ProductEntity $product): array @@ -282,19 +237,6 @@ protected function getAdditionalAttributes(ProductEntity $product): array return $attributes; } - /** - * For API Integrations, we have to remove special characters from the attribute key as a requirement for - * sending data via API. - */ - protected function getAttributeKey(?string $key): ?string - { - if ($this->pluginConfig->isIntegrationTypeApi()) { - return Utils::removeSpecialChars($key); - } - - return $key; - } - /** * @param array|string|int|bool $value * diff --git a/src/Export/Adapters/BonusAdapter.php b/src/Export/Adapters/BonusAdapter.php index 82d50c8..5ff6fa0 100644 --- a/src/Export/Adapters/BonusAdapter.php +++ b/src/Export/Adapters/BonusAdapter.php @@ -7,7 +7,7 @@ use FINDOLOGIC\Export\Data\Bonus; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class BonusAdapter +class BonusAdapter implements AdapterInterface { public function adapt(ProductEntity $product): ?Bonus { diff --git a/src/Export/Adapters/DateAddedAdapter.php b/src/Export/Adapters/DateAddedAdapter.php index 843afd7..1f3780c 100644 --- a/src/Export/Adapters/DateAddedAdapter.php +++ b/src/Export/Adapters/DateAddedAdapter.php @@ -7,7 +7,7 @@ use FINDOLOGIC\Export\Data\DateAdded; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class DateAddedAdapter +class DateAddedAdapter implements AdapterInterface { public function adapt(ProductEntity $product): ?DateAdded { diff --git a/src/Export/Adapters/DefaultPropertiesAdapter.php b/src/Export/Adapters/DefaultPropertiesAdapter.php index 0312814..b06f472 100644 --- a/src/Export/Adapters/DefaultPropertiesAdapter.php +++ b/src/Export/Adapters/DefaultPropertiesAdapter.php @@ -10,7 +10,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class DefaultPropertiesAdapter +class DefaultPropertiesAdapter implements AdapterInterface { protected ExportContext $exportContext; diff --git a/src/Export/Adapters/DescriptionAdapter.php b/src/Export/Adapters/DescriptionAdapter.php index 9c5bfee..5fadc11 100644 --- a/src/Export/Adapters/DescriptionAdapter.php +++ b/src/Export/Adapters/DescriptionAdapter.php @@ -8,7 +8,7 @@ use FINDOLOGIC\Shopware6Common\Export\Utils\Utils; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class DescriptionAdapter +class DescriptionAdapter implements AdapterInterface { public function adapt(ProductEntity $product): ?Description { diff --git a/src/Export/Adapters/ExportItemAdapter.php b/src/Export/Adapters/ExportItemAdapter.php index 2608cca..7abb0bc 100644 --- a/src/Export/Adapters/ExportItemAdapter.php +++ b/src/Export/Adapters/ExportItemAdapter.php @@ -136,13 +136,20 @@ public function adaptProduct(Item $item, ProductEntity $product): ?Item $item->addUsergroup($userGroup); } + foreach ($this->adapterFactory->getOptionsAdapter()->adapt($product) as $attribute) { + $item->addMergedAttribute($attribute); + } + return $item; } public function adaptVariant(Item $item, ProductEntity $product): ?Item { if ($this->eventDispatcher) { - $this->eventDispatcher->dispatch(new BeforeVariantAdaptEvent($product, $item), BeforeVariantAdaptEvent::NAME); + $this->eventDispatcher->dispatch( + new BeforeVariantAdaptEvent($product, $item), + BeforeVariantAdaptEvent::NAME, + ); } try { @@ -157,6 +164,10 @@ public function adaptVariant(Item $item, ProductEntity $product): ?Item foreach ($this->adapterFactory->getShopwarePropertiesAdapter()->adapt($product) as $property) { $item->addProperty($property); } + + foreach ($this->adapterFactory->getVariantConfigurationAdapter()->adapt($product) as $attribute) { + $item->addMergedAttribute($attribute); + } } catch (Throwable $exception) { $exceptionLogger = new ExportExceptionLogger($this->logger); $exceptionLogger->log($product, $exception); diff --git a/src/Export/Adapters/ImagesAdapter.php b/src/Export/Adapters/ImagesAdapter.php index aa98bf9..91b332a 100644 --- a/src/Export/Adapters/ImagesAdapter.php +++ b/src/Export/Adapters/ImagesAdapter.php @@ -7,7 +7,7 @@ use FINDOLOGIC\Export\Data\Image; use FINDOLOGIC\Shopware6Common\Export\Services\ProductImageService; -class ImagesAdapter +class ImagesAdapter implements AdapterInterface { protected ProductImageService $productImageService; diff --git a/src/Export/Adapters/KeywordsAdapter.php b/src/Export/Adapters/KeywordsAdapter.php index 3c933b1..2c52522 100644 --- a/src/Export/Adapters/KeywordsAdapter.php +++ b/src/Export/Adapters/KeywordsAdapter.php @@ -9,7 +9,7 @@ use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; use FINDOLOGIC\Shopware6Common\Export\ExportContext; -class KeywordsAdapter +class KeywordsAdapter implements AdapterInterface { protected ExportContext $exportContext; diff --git a/src/Export/Adapters/NameAdapter.php b/src/Export/Adapters/NameAdapter.php index 5b2b641..3f1145b 100644 --- a/src/Export/Adapters/NameAdapter.php +++ b/src/Export/Adapters/NameAdapter.php @@ -9,7 +9,7 @@ use FINDOLOGIC\Shopware6Common\Export\Utils\Utils; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class NameAdapter +class NameAdapter implements AdapterInterface { /** * @throws ProductHasNoNameException diff --git a/src/Export/Adapters/OptionsAdapter.php b/src/Export/Adapters/OptionsAdapter.php new file mode 100644 index 0000000..799548e --- /dev/null +++ b/src/Export/Adapters/OptionsAdapter.php @@ -0,0 +1,32 @@ +pluginConfig = $pluginConfig; + } + + /** + * @return Attribute[] + */ + public function adapt(ProductEntity $product): array + { + if (!$product->options || !$product->options->count()) { + return []; + } + + return $this->getPropertyGroupOptionAttributes($product->options); + } +} diff --git a/src/Export/Adapters/OrderNumberAdapter.php b/src/Export/Adapters/OrderNumberAdapter.php index 807600b..3981601 100644 --- a/src/Export/Adapters/OrderNumberAdapter.php +++ b/src/Export/Adapters/OrderNumberAdapter.php @@ -8,7 +8,7 @@ use FINDOLOGIC\Shopware6Common\Export\Utils\Utils; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class OrderNumberAdapter +class OrderNumberAdapter implements AdapterInterface { public function adapt(ProductEntity $product): array { diff --git a/src/Export/Adapters/PriceAdapter.php b/src/Export/Adapters/PriceAdapter.php index 6ef5096..2671bbe 100644 --- a/src/Export/Adapters/PriceAdapter.php +++ b/src/Export/Adapters/PriceAdapter.php @@ -10,7 +10,7 @@ use FINDOLOGIC\Shopware6Common\Export\Utils\Utils; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class PriceAdapter +class PriceAdapter implements AdapterInterface { protected ExportContext $exportContext; diff --git a/src/Export/Adapters/ShopwarePropertiesAdapter.php b/src/Export/Adapters/ShopwarePropertiesAdapter.php index b0fe2e7..fa6b18e 100644 --- a/src/Export/Adapters/ShopwarePropertiesAdapter.php +++ b/src/Export/Adapters/ShopwarePropertiesAdapter.php @@ -10,7 +10,7 @@ use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; use Vin\ShopwareSdk\Data\Entity\PropertyGroupOption\PropertyGroupOptionEntity; -class ShopwarePropertiesAdapter +class ShopwarePropertiesAdapter implements AdapterInterface { protected PluginConfig $pluginConfig; diff --git a/src/Export/Adapters/SortAdapter.php b/src/Export/Adapters/SortAdapter.php index 0b9776a..21c7f16 100644 --- a/src/Export/Adapters/SortAdapter.php +++ b/src/Export/Adapters/SortAdapter.php @@ -7,7 +7,7 @@ use FINDOLOGIC\Export\Data\Sort; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class SortAdapter +class SortAdapter implements AdapterInterface { public function adapt(ProductEntity $product): ?Sort { diff --git a/src/Export/Adapters/SummaryAdapter.php b/src/Export/Adapters/SummaryAdapter.php index 4b466c8..73e536f 100644 --- a/src/Export/Adapters/SummaryAdapter.php +++ b/src/Export/Adapters/SummaryAdapter.php @@ -7,7 +7,7 @@ use FINDOLOGIC\Export\Data\Summary; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class SummaryAdapter +class SummaryAdapter implements AdapterInterface { public function adapt(ProductEntity $product): ?Summary { diff --git a/src/Export/Adapters/UrlAdapter.php b/src/Export/Adapters/UrlAdapter.php index 4068827..3bd5201 100644 --- a/src/Export/Adapters/UrlAdapter.php +++ b/src/Export/Adapters/UrlAdapter.php @@ -8,7 +8,7 @@ use FINDOLOGIC\Shopware6Common\Export\Services\ProductUrlService; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class UrlAdapter +class UrlAdapter implements AdapterInterface { protected ProductUrlService $productUrlService; diff --git a/src/Export/Adapters/UserGroupsAdapter.php b/src/Export/Adapters/UserGroupsAdapter.php index 0f69c20..914f806 100644 --- a/src/Export/Adapters/UserGroupsAdapter.php +++ b/src/Export/Adapters/UserGroupsAdapter.php @@ -9,7 +9,7 @@ use Vin\ShopwareSdk\Data\Entity\CustomerGroup\CustomerGroupEntity; use Vin\ShopwareSdk\Data\Entity\Product\ProductEntity; -class UserGroupsAdapter +class UserGroupsAdapter implements AdapterInterface { protected ExportContext $exportContext; diff --git a/src/Export/Adapters/VariantConfigurationAdapter.php b/src/Export/Adapters/VariantConfigurationAdapter.php new file mode 100644 index 0000000..ff5d109 --- /dev/null +++ b/src/Export/Adapters/VariantConfigurationAdapter.php @@ -0,0 +1,54 @@ +pluginConfig = $pluginConfig; + } + + /** + * @return Attribute[] + */ + public function adapt(ProductEntity $product): array + { + $options = $product->options; + + if (!$options->count()) { + return []; + } + + $variantlisting = array_filter( + $product->variantListingConfig['configuratorGroupConfig'] ?? [], + function (array $listing) { + return $listing['expressionForListings']; + }, + ); + $variantListingGroupId = array_map(fn ($listing) => $listing['id'], $variantlisting); + + if ( + $this->pluginConfig->getMainVariant() === MainVariant::SHOPWARE_DEFAULT && + !$product->variantListingConfig['displayParent'] && + count($variantlisting) + ) { + $options = $options->filter(function (PropertyGroupOptionEntity $option) use ($variantListingGroupId) { + return !in_array($option->groupId, $variantListingGroupId); + }); + } + + return $this->getPropertyGroupOptionAttributes($options); + } +} diff --git a/src/Traits/AdapterHelper.php b/src/Traits/AdapterHelper.php new file mode 100644 index 0000000..c848616 --- /dev/null +++ b/src/Traits/AdapterHelper.php @@ -0,0 +1,69 @@ +group; + if ($group && !$group->filterable) { + continue; + } + $attributes = array_merge($attributes, $this->getAttributePropertyAsAttribute($propertyGroupOptionEntity)); + } + + return $attributes; + } + + /** + * @return Attribute[] + */ + protected function getAttributePropertyAsAttribute(PropertyGroupOptionEntity $propertyGroupOptionEntity): array + { + $attributes = []; + + $group = $propertyGroupOptionEntity->group; + if ($group && $propertyGroupOptionEntity->getTranslation('name') && $group->getTranslation('name')) { + $groupName = $this->getAttributeKey($group->getTranslation('name')); + $propertyGroupOptionName = $propertyGroupOptionEntity->getTranslation('name'); + if (!Utils::isEmpty($groupName) && !Utils::isEmpty($propertyGroupOptionName)) { + $propertyGroupAttrib = new Attribute($groupName); + $propertyGroupAttrib->addValue(Utils::removeControlCharacters($propertyGroupOptionName)); + + $attributes[] = $propertyGroupAttrib; + } + } + + return $attributes; + } + + /** + * For API Integrations, we have to remove special characters from the attribute key as a requirement for + * sending data via API. + */ + protected function getAttributeKey(?string $key): ?string + { + if ($this->pluginConfig->isIntegrationTypeApi()) { + return Utils::removeSpecialChars($key); + } + + return $key; + } +} diff --git a/tests/Export/Adapters/AttributeAdapterTest.php b/tests/Export/Adapters/AttributeAdapterTest.php index 91e79dd..19ec231 100644 --- a/tests/Export/Adapters/AttributeAdapterTest.php +++ b/tests/Export/Adapters/AttributeAdapterTest.php @@ -344,8 +344,7 @@ public function testEmptyCategoryNameShouldStillExportCategory(): void ); $attributes = $this->attributeAdapter->adapt($productEntity); - - $this->assertCount(7, $attributes); + $this->assertCount(5, $attributes); $this->assertSame('cat_url', $attributes[0]->getKey()); $catUrls = $attributes[0]->getValues(); @@ -419,7 +418,6 @@ public function testOnlyUniqueCategoriesAreExported(bool $isParentAssigned, bool $attributes = $reflector->getProperty('attributes'); $attributes->setAccessible(true); $value = $attributes->getValue($item); - $this->assertArrayHasKey('cat_url', $value); $categoryUrlAttributeValues = $value['cat_url']->getValues(); $this->assertSame($expectedCatUrls, $categoryUrlAttributeValues); diff --git a/tests/Export/Adapters/OptionAdapterTest.php b/tests/Export/Adapters/OptionAdapterTest.php new file mode 100644 index 0000000..d8c15d4 --- /dev/null +++ b/tests/Export/Adapters/OptionAdapterTest.php @@ -0,0 +1,39 @@ +pluginConfig = $this->getPluginConfig(); + $this->optionsAdapter = $this->getOptionsAdapter($this->pluginConfig); + } + + public function testGetOptionAttributes(): void + { + $id = Uuid::randomHex(); + $product = $this->createTestProduct([ + 'id' => $id, + ]); + $attributes = $this->optionsAdapter->adapt($product); + + $this->assertCount(2, $attributes); + $this->assertSame('red', $attributes[0]->getValues()[0]); + $this->assertSame('blue', $attributes[1]->getValues()[0]); + } +} diff --git a/tests/Export/Adapters/VariantConfigurationAdapterTest.php b/tests/Export/Adapters/VariantConfigurationAdapterTest.php new file mode 100644 index 0000000..74ea620 --- /dev/null +++ b/tests/Export/Adapters/VariantConfigurationAdapterTest.php @@ -0,0 +1,38 @@ +pluginConfig = $this->getPluginConfig(); + $this->variantConfigurationAdapter = $this->getVariantConfigurationAdapter($this->pluginConfig); + } + + public function testGetVariantAttributes(): void + { + $id = Uuid::randomHex(); + $product = $this->createTestProduct([ + 'id' => $id, + ]); + $attributes = $this->variantConfigurationAdapter->adapt($product); + $this->assertCount(2, $attributes); + $this->assertSame('red', $attributes[0]->getValues()[0]); + $this->assertSame('blue', $attributes[1]->getValues()[0]); + } +} diff --git a/tests/Traits/AdapterHelper.php b/tests/Traits/AdapterHelper.php index 077cabc..aa6472a 100644 --- a/tests/Traits/AdapterHelper.php +++ b/tests/Traits/AdapterHelper.php @@ -15,6 +15,7 @@ use FINDOLOGIC\Shopware6Common\Export\Adapters\ImagesAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\KeywordsAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\NameAdapter; +use FINDOLOGIC\Shopware6Common\Export\Adapters\OptionsAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\OrderNumberAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\PriceAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\ShopwarePropertiesAdapter; @@ -22,6 +23,7 @@ use FINDOLOGIC\Shopware6Common\Export\Adapters\SummaryAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\UrlAdapter; use FINDOLOGIC\Shopware6Common\Export\Adapters\UserGroupsAdapter; +use FINDOLOGIC\Shopware6Common\Export\Adapters\VariantConfigurationAdapter; use FINDOLOGIC\Shopware6Common\Export\Config\PluginConfig; use Monolog\Logger; use Psr\EventDispatcher\EventDispatcherInterface; @@ -45,6 +47,7 @@ public function getAdapterFactory(?PluginConfig $config = null): AdapterFactory $this->getImagesAdapter(), $this->getKeywordsAdapter(), $this->getNameAdapter(), + $this->getOptionsAdapter($config), $this->getOrderNumberAdapter(), $this->getPriceAdapter(), $this->getSalesFrequencyAdapter(), @@ -53,6 +56,7 @@ public function getAdapterFactory(?PluginConfig $config = null): AdapterFactory $this->getShopwarePropertiesAdapter(), $this->getUrlAdapter(), $this->getUserGroupAdapter(), + $this->getVariantConfigurationAdapter($config), ); } @@ -115,6 +119,11 @@ public function getNameAdapter(): NameAdapter return new NameAdapter(); } + public function getOptionsAdapter(?PluginConfig $config = null): OptionsAdapter + { + return new OptionsAdapter($config ?? $this->getPluginConfig()); + } + public function getOrderNumberAdapter(): OrderNumberAdapter { return new OrderNumberAdapter(); @@ -170,4 +179,9 @@ public function getUserGroupAdapter(?CustomerGroupCollection $customerGroupColle { return new UserGroupsAdapter($this->getExportContext($customerGroupCollection)); } + + public function getVariantConfigurationAdapter(?PluginConfig $config = null): VariantConfigurationAdapter + { + return new VariantConfigurationAdapter($config ?? $this->getPluginConfig()); + } } diff --git a/tests/Traits/AttributeHelper.php b/tests/Traits/AttributeHelper.php index 2c22c82..e8dae80 100644 --- a/tests/Traits/AttributeHelper.php +++ b/tests/Traits/AttributeHelper.php @@ -47,13 +47,6 @@ public function getAttributes(ProductEntity $productEntity, string $integrationT ], ); - foreach ($productEntity->options ?? [] as $option) { - $attributes[] = new Attribute( - $option->group->name, - [$option->name], - ); - } - $shippingFree = $this->translateBooleanValue((bool) $productEntity->shippingFree); $attributes[] = new Attribute('shipping_free', [$shippingFree]); diff --git a/tests/Traits/ProductHelper.php b/tests/Traits/ProductHelper.php index b3faa58..05ead7c 100644 --- a/tests/Traits/ProductHelper.php +++ b/tests/Traits/ProductHelper.php @@ -52,6 +52,7 @@ public function createTestProduct( 'description' => 'FINDOLOGIC Description', ], 'streamIds' => [], + 'variantListingConfig' => ['displayParent' => null], ]); $productData = array_merge_recursive( diff --git a/tests/Traits/ServicesHelper.php b/tests/Traits/ServicesHelper.php index fa327cc..d24c185 100644 --- a/tests/Traits/ServicesHelper.php +++ b/tests/Traits/ServicesHelper.php @@ -132,6 +132,7 @@ public function getPluginConfig(?array $overrides = []): PluginConfig return PluginConfig::createFromArray(array_merge([ 'shopkey' => 'ABCDABCDABCDABCDABCDABCDABCDABCD', 'active' => true, + 'mainVariant' => 'default', ], $overrides)); }