From b51e2ff560d3307df7cb6d1c3cd4e356d7b0ea0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Wed, 3 Jan 2024 12:42:50 +0100 Subject: [PATCH 1/3] fixed ignoring root category --- src/Model/FeedItem/PersooFeedItemFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/FeedItem/PersooFeedItemFactory.php b/src/Model/FeedItem/PersooFeedItemFactory.php index a610cc1..ef1a257 100644 --- a/src/Model/FeedItem/PersooFeedItemFactory.php +++ b/src/Model/FeedItem/PersooFeedItemFactory.php @@ -60,7 +60,7 @@ public function create(Product $product, DomainConfig $domainConfig): PersooFeed $categoryHierarchyNames[] = $category->getName($locale); $categoryHierarchyIds[] = $category->getId(); - while ($parent !== null && $parent !== $rootCategory) { + while ($parent !== null && $parent->getId() !== $rootCategory->getId()) { $categoryHierarchyIds[] = $parent->getId(); $categoryHierarchyNames[] = $parent->getName($locale); $parent = $parent->getParent(); From 7a8a552e2083cc30175d2255c84a423af602c026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Wed, 3 Jan 2024 12:45:42 +0100 Subject: [PATCH 2/3] product availability in Persoo Product feed is now retrieved from ProductAvailabilityFacade --- src/Model/FeedItem/PersooFeedItemFactory.php | 8 ++++---- tests/Unit/PersooFeedItemTest.php | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Model/FeedItem/PersooFeedItemFactory.php b/src/Model/FeedItem/PersooFeedItemFactory.php index ef1a257..c737b0d 100644 --- a/src/Model/FeedItem/PersooFeedItemFactory.php +++ b/src/Model/FeedItem/PersooFeedItemFactory.php @@ -6,11 +6,11 @@ use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig; use Shopsys\FrameworkBundle\Component\String\TransformString; -use Shopsys\FrameworkBundle\Component\Translation\Translator; use Shopsys\FrameworkBundle\Model\Category\CategoryRepository; use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade; use Shopsys\FrameworkBundle\Model\Pricing\Price; +use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade; use Shopsys\FrameworkBundle\Model\Product\Collection\ProductUrlsBatchLoader; use Shopsys\FrameworkBundle\Model\Product\Flag\Flag; use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPriceCalculationForCustomerUser; @@ -25,6 +25,7 @@ class PersooFeedItemFactory * @param \Shopsys\FrameworkBundle\Model\Product\Collection\ProductUrlsBatchLoader $productUrlsBatchLoader * @param \Shopsys\FrameworkBundle\Model\Category\CategoryRepository $categoryRepository * @param \Shopsys\FrameworkBundle\Model\Product\ProductCachedAttributesFacade $productCachedAttributesFacade + * @param \Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade $productAvailabilityFacade */ public function __construct( protected readonly ProductPriceCalculationForCustomerUser $productPriceCalculationForCustomerUser, @@ -32,6 +33,7 @@ public function __construct( protected readonly ProductUrlsBatchLoader $productUrlsBatchLoader, protected readonly CategoryRepository $categoryRepository, protected readonly ProductCachedAttributesFacade $productCachedAttributesFacade, + protected readonly ProductAvailabilityFacade $productAvailabilityFacade, ) { } @@ -45,9 +47,7 @@ public function create(Product $product, DomainConfig $domainConfig): PersooFeed $locale = $domainConfig->getLocale(); $rootCategory = $this->categoryRepository->getRootCategory(); $mainCategory = $this->categoryRepository->getProductMainCategoryOnDomain($product, $domainConfig->getId()); - $availability = $product->getCalculatedSellingDenied() === true ? - t('Out of stock', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $locale) : - t('In stock', [], Translator::DEFAULT_TRANSLATION_DOMAIN, $locale); + $availability = $this->productAvailabilityFacade->getProductAvailabilityInformationByDomainId($product, $domainConfig->getId()); $productDescription = $product->isVariant() ? $product->getMainVariant()->getDescriptionAsPlainText($domainConfig->getId()) : $product->getDescriptionAsPlainText($domainConfig->getId()); $categories = $product->getCategoriesIndexedByDomainId()[$domainConfig->getId()]; $categoryHierarchyNamesByCategoryId = []; diff --git a/tests/Unit/PersooFeedItemTest.php b/tests/Unit/PersooFeedItemTest.php index bca6d70..2365fe3 100644 --- a/tests/Unit/PersooFeedItemTest.php +++ b/tests/Unit/PersooFeedItemTest.php @@ -15,6 +15,7 @@ use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade; use Shopsys\FrameworkBundle\Model\Pricing\Price; +use Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityFacade; use Shopsys\FrameworkBundle\Model\Product\Brand\Brand; use Shopsys\FrameworkBundle\Model\Product\Collection\ProductUrlsBatchLoader; use Shopsys\FrameworkBundle\Model\Product\Flag\Flag; @@ -120,12 +121,15 @@ protected function setUp(): void $productCachedAttributesFacade = $this->createMock(ProductCachedAttributesFacade::class); $productCachedAttributesFacade->method('getProductParameterValues')->willReturn([$productParameterValue]); + $productAvailabilityFacade = $this->createMock(ProductAvailabilityFacade::class); + $this->persooFeedItemFactory = new PersooFeedItemFactory( $this->productPriceCalculationForCustomerUserMock, $this->currencyFacadeMock, $this->productUrlsBatchLoaderMock, $categoryRepositoryMock, $productCachedAttributesFacade, + $productAvailabilityFacade, ); } From 70b5d83daf14adb5eadbcf9f0e8532a6058a070d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Ludvik?= Date: Wed, 3 Jan 2024 12:48:21 +0100 Subject: [PATCH 3/3] removed currency code from Persoo product feed --- src/Resources/views/feed.xml.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/feed.xml.twig b/src/Resources/views/feed.xml.twig index bfdb6b6..49708e4 100644 --- a/src/Resources/views/feed.xml.twig +++ b/src/Resources/views/feed.xml.twig @@ -29,7 +29,7 @@ {{ item.imageLink }} {% endif -%} {{ item.availability }} - {{ item.price.priceWithVat|moneyFormat(2) }} {{ item.currency.code }} + {{ item.price.priceWithVat|moneyFormat(2) }} {% if item.brand is not null -%} {{ item.brand }} {% endif -%}