diff --git a/src/AttributeDataSet.php b/src/AttributeDataSet.php index 09a3835..182afa5 100644 --- a/src/AttributeDataSet.php +++ b/src/AttributeDataSet.php @@ -1,6 +1,8 @@ withTimestamp($timestamp); + }, $this->items); + } + private static function getKey(AttributeData $attributeData): string { return $attributeData->getId(); diff --git a/src/AttributeOptionSet.php b/src/AttributeOptionSet.php index 802b5d6..5bac8c8 100644 --- a/src/AttributeOptionSet.php +++ b/src/AttributeOptionSet.php @@ -2,6 +2,8 @@ declare(strict_types=1); namespace SnowIO\FredhopperDataModel; +use SnowIO\FredhopperDataModel\Command\SaveAttributeOptionCommand; + final class AttributeOptionSet implements \IteratorAggregate { use SetTrait; @@ -14,6 +16,13 @@ public function with(AttributeOption $attributeOption): self return $result; } + public function mapToSaveCommands(int $timestamp): array + { + return \array_map(function (AttributeOption $attributeOption) use ($timestamp) { + return SaveAttributeOptionCommand::of($attributeOption)->withTimestamp($timestamp); + }, $this->items); + } + private static function getKey(AttributeOption $attributeOption): string { return "{$attributeOption->getAttributeId()}-{$attributeOption->getValueId()}"; diff --git a/src/CategoryDataSet.php b/src/CategoryDataSet.php index 29bcc36..d3f6196 100644 --- a/src/CategoryDataSet.php +++ b/src/CategoryDataSet.php @@ -1,6 +1,8 @@ withTimestamp($timestamp); + }, $this->items); + } + private static function getKey(CategoryData $categoryData): string { return $categoryData->getId(); diff --git a/src/ProductDataSet.php b/src/ProductDataSet.php index ea73068..66855b6 100644 --- a/src/ProductDataSet.php +++ b/src/ProductDataSet.php @@ -1,6 +1,8 @@ withTimestamp($timestamp); + }, $this->items); + } + private static function getKey(ProductData $productData): string { return $productData->getId(); diff --git a/src/VariantDataSet.php b/src/VariantDataSet.php index 463819e..a7e4e29 100644 --- a/src/VariantDataSet.php +++ b/src/VariantDataSet.php @@ -1,6 +1,8 @@ withTimestamp($timestamp); + }, $this->items); + } + private static function getKey(VariantData $variantData): string { return $variantData->getId();