diff --git a/src/Factory/ProductListViewFactory.php b/src/Factory/ProductListViewFactory.php index b2c1b49..da528b3 100644 --- a/src/Factory/ProductListViewFactory.php +++ b/src/Factory/ProductListViewFactory.php @@ -201,10 +201,13 @@ private function getProductView(ProductDocument $product) $productView->channelCode = $product->getChannelCode(); $productView->images = $this->getImageViews($product->getImages()); $productView->taxons = $this->getTaxonViews($product->getTaxons()); - $productView->mainTaxon = $this->getTaxonView($product->getMainTaxon()); $productView->attributes = $this->getAttributeViews($product->getAttributeValues()); $productView->variants = [$this->getVariantView($product)]; + if (null !== $product->getMainTaxon()) { + $productView->mainTaxon = $this->getTaxonView($product->getMainTaxon()); + } + return $productView; } } diff --git a/tests/DataFixtures/ORM/shop.yml b/tests/DataFixtures/ORM/shop.yml index 6d6f907..a9ca29a 100644 --- a/tests/DataFixtures/ORM/shop.yml +++ b/tests/DataFixtures/ORM/shop.yml @@ -42,20 +42,31 @@ Sylius\Component\Core\Model\Product: currentTranslation: "@en_gb_mug_product_translation" translations: ["@en_gb_mug_product_translation", "@de_de_mug_product_translation"] mainTaxon: "@mug_taxon" - productTaxons: ["@mug_product_taxon"] + productTaxons: ["@mug_product_taxon", "@mug_brand_taxon"] attributes: - "@en_gb_mug_holiday_collection_value" - "@de_de_mug_holiday_collection_value" - "@en_gb_mug_wood_material_value" - "@de_de_mug_wood_material_value" variants: ["@mug_variant"] + hat: + code: "LOGAN_HAT_CODE" + channels: ["@gb_web_channel"] + currentLocale: "en_GB" + currentTranslation: "@en_gb_hat_product_translation" + translations: ["@en_gb_hat_product_translation", "@de_de_hat_product_translation"] + productTaxons: ["@hat_product_taxon", "@hat_brand_taxon"] + attributes: + - "@en_gb_mug_holiday_collection_value" + - "@de_de_mug_holiday_collection_value" + variants: ["@hat_variant"] t_shirt: code: "LOGAN_T_SHIRT_CODE" channels: ["@gb_web_channel"] currentLocale: "en_GB" currentTranslation: "@t_shirt_translation" mainTaxon: "@t_shirt_taxon" - productTaxons: ["@t_shirt_product_taxon"] + productTaxons: ["@t_shirt_product_taxon", "@t_shirt_brand_taxon"] variants: ["@t_shirt_small"] Sylius\Component\Core\Model\ProductTranslation: @@ -71,6 +82,18 @@ Sylius\Component\Core\Model\ProductTranslation: name: "Logan Becher" description: translatable: "@mug" + en_gb_hat_product_translation: + slug: "logan-hat" + locale: "en_GB" + name: "Logan Hat" + description: + translatable: "@hat" + de_de_hat_product_translation: + slug: "logan-hut" + locale: "de_DE" + name: "Logan Hut" + description: + translatable: "@hat" t_shirt_translation: slug: "logan-t-shirt" locale: "en_GB" @@ -87,6 +110,14 @@ Sylius\Component\Core\Model\ProductVariant: translations: ["@en_gb_mug_variant_translation", "@de_de_mug_variant_translation"] channelPricings: WEB_GB: "@gb_mug_web_channel_pricing" + hat_variant: + code: "LOGAN_HAT_CODE" + product: "@hat" + currentLocale: "en_GB" + currentTranslation: "@en_gb_hat_variant_translation" + translations: ["@en_gb_hat_variant_translation", "@de_de_hat_variant_translation"] + channelPricings: + WEB_GB: "@gb_hat_web_channel_pricing" t_shirt_small: code: "SMALL_LOGAN_T_SHIRT_CODE" product: "@t_shirt" @@ -104,6 +135,14 @@ Sylius\Component\Product\Model\ProductVariantTranslation: locale: "de_DE" name: "Logan Becher" translatable: "@mug_variant" + en_gb_hat_variant_translation: + locale: "en_GB" + name: "Logan Hat" + translatable: "@hat_variant" + de_de_hat_variant_translation: + locale: "de_DE" + name: "Logan Hut" + translatable: "@hat_variant" small_t_shirt_translation: locale: "en_GB" name: "Small Logan T-Shirt" @@ -113,6 +152,9 @@ Sylius\Component\Core\Model\ChannelPricing: gb_mug_web_channel_pricing: channelCode: "WEB_GB" price: 1999 + gb_hat_web_channel_pricing: + channelCode: "WEB_GB" + price: 2999 gb_small_t_shirt_web_channel_pricing: channelCode: "WEB_GB" price: 1999 @@ -131,6 +173,13 @@ Sylius\Component\Core\Model\Taxon: translations: ["@en_gb_mug_taxon_translation", "@de_de_mug_taxon_translation"] parent: "@category_taxon" root: "@category_taxon" + hat_taxon: + code: "HAT" + currentLocale: "en_GB" + currentTranslation: "@en_gb_hat_taxon_translation" + translations: ["@en_gb_hat_taxon_translation", "@de_de_hat_taxon_translation"] + parent: "@category_taxon" + root: "@category_taxon" t_shirt_taxon: code: "T_SHIRTS" currentLocale: "en_GB" @@ -169,6 +218,12 @@ Sylius\Component\Taxonomy\Model\TaxonTranslation: name: "Brands" description: translatable: "@brand_taxon" + en_gb_hat_taxon_translation: + slug: "categories/hats" + locale: "en_GB" + name: "Hats" + description: + translatable: "@hat_taxon" de_de_category_translation: slug: "kategorien" locale: "de_DE" @@ -193,17 +248,29 @@ Sylius\Component\Taxonomy\Model\TaxonTranslation: name: "Marken" description: translatable: "@brand_taxon" + de_de_hat_taxon_translation: + slug: "kategorien/hut" + locale: "de_DE" + name: "Hut" + description: + translatable: "@hat_taxon" Sylius\Component\Core\Model\ProductTaxon: mug_product_taxon: product: "@mug" taxon: "@mug_taxon" + hat_product_taxon: + product: "@hat" + taxon: "@hat_taxon" t_shirt_product_taxon: product: "@t_shirt" taxon: "@t_shirt_taxon" mug_brand_taxon: product: "@mug" taxon: "@brand_taxon" + hat_brand_taxon: + product: "@hat" + taxon: "@brand_taxon" t_shirt_brand_taxon: product: "@t_shirt" taxon: "@brand_taxon" diff --git a/tests/Responses/Expected/mugs_list_page.json b/tests/Responses/Expected/mugs_list_page.json index 3caacc4..77d4128 100644 --- a/tests/Responses/Expected/mugs_list_page.json +++ b/tests/Responses/Expected/mugs_list_page.json @@ -11,6 +11,13 @@ "position": 0, "images": [], "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" } ], "variants": [ @@ -57,6 +64,13 @@ "position": 0, "images": [], "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" } ], "variants": [ @@ -125,7 +139,7 @@ "taxon_slug": { "state": { "active": true, - "value": "categories/mugs", + "value": "categories\/mugs", "urlParameters": { "taxon_slug": "categories\/mugs" }, @@ -139,6 +153,15 @@ "resetUrlParameters": [], "name": "taxon_slug", "choices": [ + { + "active": false, + "default": false, + "urlParameters": { + "taxon_slug": "categories\/hats" + }, + "label": "categories\/hats", + "count": 2 + }, { "active": true, "default": false, @@ -154,6 +177,15 @@ }, "label": "categories\/t-shirts", "count": 2 + }, + { + "active": false, + "default": false, + "urlParameters": { + "taxon_slug": "brands" + }, + "label": "brands", + "count": 6 } ] }, @@ -173,7 +205,7 @@ }, "name": "price_range", "minBounds": 1999, - "maxBounds": 1999 + "maxBounds": 2999 }, "locale": { "state": { diff --git a/tests/Responses/Expected/product_list_page.json b/tests/Responses/Expected/product_list_page.json index 0d5a674..c182571 100644 --- a/tests/Responses/Expected/product_list_page.json +++ b/tests/Responses/Expected/product_list_page.json @@ -11,6 +11,13 @@ "position": 0, "images": [], "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" } ], "variants": [ @@ -57,6 +64,13 @@ "position": 0, "images": [], "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" } ], "variants": [ @@ -92,6 +106,90 @@ "description": "@string@" } }, + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hat", + "slug": "logan-hat", + "taxons": [ + { + "code": "HAT", + "slug": "categories\/hats", + "position": 2, + "images": [], + "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" + } + ], + "variants": [ + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hat", + "price": { + "current": 2999, + "currency": "GBP" + }, + "images": [] + } + ], + "attributes": [ + { + "code": "MUG_COLLECTION_CODE", + "name": "Mug collection", + "value": "HOLIDAY COLLECTION" + } + ], + "images": [], + "channelCode": "WEB_GB", + "localeCode": "en_GB" + }, + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hut", + "slug": "logan-hut", + "taxons": [ + { + "code": "HAT", + "slug": "categories\/hats", + "position": 2, + "images": [], + "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" + } + ], + "variants": [ + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hut", + "price": { + "current": 2999, + "currency": "GBP" + }, + "images": [] + } + ], + "attributes": [ + { + "code": "MUG_COLLECTION_CODE", + "name": "Mug collection", + "value": "FEIERTAGSKOLLEKTION" + } + ], + "images": [], + "channelCode": "WEB_GB", + "localeCode": "de_DE" + }, { "code": "LOGAN_T_SHIRT_CODE", "name": "Logan T-Shirt", @@ -103,6 +201,13 @@ "position": 1, "images": [], "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" } ], "variants": [ @@ -136,6 +241,13 @@ "position": 1, "images": [], "description": "@string@" + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "@string@" } ], "variants": [ @@ -180,7 +292,7 @@ "channel": "WEB_GB" }, "label": "WEB_GB", - "count": 4 + "count": 6 } ] }, @@ -196,6 +308,15 @@ "resetUrlParameters": [], "name": "taxon_slug", "choices": [ + { + "active": false, + "default": false, + "urlParameters": { + "taxon_slug": "categories\/hats" + }, + "label": "categories\/hats", + "count": 2 + }, { "active": false, "default": false, @@ -213,6 +334,15 @@ }, "label": "categories\/t-shirts", "count": 2 + }, + { + "active": false, + "default": false, + "urlParameters": { + "taxon_slug": "brands" + }, + "label": "brands", + "count": 6 } ] }, @@ -228,7 +358,7 @@ "resetUrlParameters": [], "name": "price_range", "minBounds": 1999, - "maxBounds": 1999 + "maxBounds": 2999 }, "locale": { "state": { @@ -249,7 +379,7 @@ "locale_code": "de_DE" }, "label": "de_DE", - "count": 2 + "count": 3 }, { "active": false, @@ -258,7 +388,7 @@ "locale_code": "en_GB" }, "label": "en_GB", - "count": 2 + "count": 3 } ] }, @@ -279,10 +409,10 @@ "default": false, "urlParameters": { "attribute_values": [ - "FEIERTAGSKOLLEKTION" + "Holz" ] }, - "label": "FEIERTAGSKOLLEKTION", + "label": "Holz", "count": 1 }, { @@ -290,10 +420,10 @@ "default": false, "urlParameters": { "attribute_values": [ - "HOLIDAY COLLECTION" + "Wood" ] }, - "label": "HOLIDAY COLLECTION", + "label": "Wood", "count": 1 }, { @@ -301,22 +431,22 @@ "default": false, "urlParameters": { "attribute_values": [ - "Holz" + "FEIERTAGSKOLLEKTION" ] }, - "label": "Holz", - "count": 1 + "label": "FEIERTAGSKOLLEKTION", + "count": 2 }, { "active": false, "default": false, "urlParameters": { "attribute_values": [ - "Wood" + "HOLIDAY COLLECTION" ] }, - "label": "Wood", - "count": 1 + "label": "HOLIDAY COLLECTION", + "count": 2 } ] }, @@ -333,7 +463,7 @@ "resetUrlParameters": [], "name": "paginator", "currentPage": 1, - "totalItems": 4, + "totalItems": 6, "maxPages": 10, "itemsPerPage": 10, "numPages": 1, diff --git a/tests/Responses/Expected/product_list_page_by_en_gb_channel.json b/tests/Responses/Expected/product_list_page_by_en_gb_channel.json index fdcc205..0abcba3 100644 --- a/tests/Responses/Expected/product_list_page_by_en_gb_channel.json +++ b/tests/Responses/Expected/product_list_page_by_en_gb_channel.json @@ -10,7 +10,14 @@ "slug": "categories\/mugs", "position": 0, "images": [], - "description": "@string@" + "description": "Et natus voluptas quo qui. Sunt accusamus nihil odit provident. Nemo vel amet voluptatem enim ipsam recusandae omnis." + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "Esse aut et consequatur similique corrupti. Quas cupiditate quae repellendus eaque. Itaque amet eveniet enim laborum autem repellat." } ], "variants": [ @@ -43,7 +50,7 @@ "code": "MUG", "slug": "categories\/mugs", "images": [], - "description": "@string@" + "description": "Et natus voluptas quo qui. Sunt accusamus nihil odit provident. Nemo vel amet voluptatem enim ipsam recusandae omnis." } }, { @@ -56,7 +63,14 @@ "slug": "categories\/mugs", "position": 0, "images": [], - "description": "@string@" + "description": "Et natus voluptas quo qui. Sunt accusamus nihil odit provident. Nemo vel amet voluptatem enim ipsam recusandae omnis." + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "Esse aut et consequatur similique corrupti. Quas cupiditate quae repellendus eaque. Itaque amet eveniet enim laborum autem repellat." } ], "variants": [ @@ -89,9 +103,93 @@ "code": "MUG", "slug": "categories\/mugs", "images": [], - "description": "@string@" + "description": "Et natus voluptas quo qui. Sunt accusamus nihil odit provident. Nemo vel amet voluptatem enim ipsam recusandae omnis." } }, + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hat", + "slug": "logan-hat", + "taxons": [ + { + "code": "HAT", + "slug": "categories\/hats", + "position": 2, + "images": [], + "description": "Rem ea similique enim vitae exercitationem voluptatem. Magnam dolorem saepe officia quis. Tenetur est iure nihil et voluptatem." + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "Esse aut et consequatur similique corrupti. Quas cupiditate quae repellendus eaque. Itaque amet eveniet enim laborum autem repellat." + } + ], + "variants": [ + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hat", + "price": { + "current": 2999, + "currency": "GBP" + }, + "images": [] + } + ], + "attributes": [ + { + "code": "MUG_COLLECTION_CODE", + "name": "Mug collection", + "value": "HOLIDAY COLLECTION" + } + ], + "images": [], + "channelCode": "WEB_GB", + "localeCode": "en_GB" + }, + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hut", + "slug": "logan-hut", + "taxons": [ + { + "code": "HAT", + "slug": "categories\/hats", + "position": 2, + "images": [], + "description": "Rem ea similique enim vitae exercitationem voluptatem. Magnam dolorem saepe officia quis. Tenetur est iure nihil et voluptatem." + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "Esse aut et consequatur similique corrupti. Quas cupiditate quae repellendus eaque. Itaque amet eveniet enim laborum autem repellat." + } + ], + "variants": [ + { + "code": "LOGAN_HAT_CODE", + "name": "Logan Hut", + "price": { + "current": 2999, + "currency": "GBP" + }, + "images": [] + } + ], + "attributes": [ + { + "code": "MUG_COLLECTION_CODE", + "name": "Mug collection", + "value": "FEIERTAGSKOLLEKTION" + } + ], + "images": [], + "channelCode": "WEB_GB", + "localeCode": "de_DE" + }, { "code": "LOGAN_T_SHIRT_CODE", "name": "Logan T-Shirt", @@ -102,7 +200,14 @@ "slug": "categories\/t-shirts", "position": 1, "images": [], - "description": "@string@" + "description": "Nobis doloribus recusandae ut aliquam sit numquam fuga. Et et esse quia voluptatem." + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "Esse aut et consequatur similique corrupti. Quas cupiditate quae repellendus eaque. Itaque amet eveniet enim laborum autem repellat." } ], "variants": [ @@ -124,7 +229,7 @@ "code": "T_SHIRTS", "slug": "categories\/t-shirts", "images": [], - "description": "@string@" + "description": "Nobis doloribus recusandae ut aliquam sit numquam fuga. Et et esse quia voluptatem." } }, { @@ -135,7 +240,14 @@ "slug": "categories\/t-shirts", "position": 1, "images": [], - "description": "@string@" + "description": "Nobis doloribus recusandae ut aliquam sit numquam fuga. Et et esse quia voluptatem." + }, + { + "code": "BRAND", + "slug": "brands", + "position": 1, + "images": [], + "description": "Esse aut et consequatur similique corrupti. Quas cupiditate quae repellendus eaque. Itaque amet eveniet enim laborum autem repellat." } ], "variants": [ @@ -156,7 +268,7 @@ "code": "T_SHIRTS", "slug": "categories\/t-shirts", "images": [], - "description": "@string@" + "description": "Nobis doloribus recusandae ut aliquam sit numquam fuga. Et et esse quia voluptatem." } } ], @@ -183,7 +295,7 @@ "default": false, "urlParameters": [], "label": "WEB_GB", - "count": 4 + "count": 6 } ] }, @@ -203,6 +315,16 @@ }, "name": "taxon_slug", "choices": [ + { + "active": false, + "default": false, + "urlParameters": { + "channel": "WEB_GB", + "taxon_slug": "categories\/hats" + }, + "label": "categories\/hats", + "count": 2 + }, { "active": false, "default": false, @@ -222,6 +344,16 @@ }, "label": "categories\/t-shirts", "count": 2 + }, + { + "active": false, + "default": false, + "urlParameters": { + "channel": "WEB_GB", + "taxon_slug": "brands" + }, + "label": "brands", + "count": 6 } ] }, @@ -241,7 +373,7 @@ }, "name": "price_range", "minBounds": 1999, - "maxBounds": 1999 + "maxBounds": 2999 }, "locale": { "state": { @@ -267,7 +399,7 @@ "locale_code": "de_DE" }, "label": "de_DE", - "count": 2 + "count": 3 }, { "active": false, @@ -277,7 +409,7 @@ "locale_code": "en_GB" }, "label": "en_GB", - "count": 2 + "count": 3 } ] }, @@ -303,10 +435,10 @@ "urlParameters": { "channel": "WEB_GB", "attribute_values": [ - "FEIERTAGSKOLLEKTION" + "Holz" ] }, - "label": "FEIERTAGSKOLLEKTION", + "label": "Holz", "count": 1 }, { @@ -315,10 +447,10 @@ "urlParameters": { "channel": "WEB_GB", "attribute_values": [ - "HOLIDAY COLLECTION" + "Wood" ] }, - "label": "HOLIDAY COLLECTION", + "label": "Wood", "count": 1 }, { @@ -327,11 +459,11 @@ "urlParameters": { "channel": "WEB_GB", "attribute_values": [ - "Holz" + "FEIERTAGSKOLLEKTION" ] }, - "label": "Holz", - "count": 1 + "label": "FEIERTAGSKOLLEKTION", + "count": 2 }, { "active": false, @@ -339,11 +471,11 @@ "urlParameters": { "channel": "WEB_GB", "attribute_values": [ - "Wood" + "HOLIDAY COLLECTION" ] }, - "label": "Wood", - "count": 1 + "label": "HOLIDAY COLLECTION", + "count": 2 } ] }, @@ -364,7 +496,7 @@ }, "name": "paginator", "currentPage": 1, - "totalItems": 4, + "totalItems": 6, "maxPages": 10, "itemsPerPage": 10, "numPages": 1,