From c036c7f8c19404cbe89a087c0032410f5dc36bab Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Sun, 9 Apr 2023 19:15:55 +0300 Subject: [PATCH] Return back child products into feed. Fix issue with feed urls. --- Helper/Data.php | 4 +--- Service/GenerateFeed.php | 13 ++++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 7d14fb3..cf296f5 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -447,9 +447,7 @@ public function getFeedUrl(): ?string { if ($store = $this->getCurrentStore()) { /* @phpstan-ignore-next-line */ - $baseUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA); - $baseUrl = str_replace(UrlInterface::URL_TYPE_MEDIA . '/', '', $baseUrl); - + $baseUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_WEB); return $baseUrl . self::FEED_DIR . $this->getFeedFilename(); } diff --git a/Service/GenerateFeed.php b/Service/GenerateFeed.php index ce48fc9..21b1829 100644 --- a/Service/GenerateFeed.php +++ b/Service/GenerateFeed.php @@ -282,12 +282,12 @@ protected function generateFeed(): void if ($attributeValue = $this->getAttributeValue($product, 'size')) { $item->addChild('SIZE', $attributeValue); - } - if ($attributeValue = $this->getAttributeValue($product, 'size_system')) { - $item->addChild('SIZE_SYSTEM', $attributeValue); - } else { - $item->addChild('SIZE_SYSTEM', 'INT'); + if ($attributeValue = $this->getAttributeValue($product, 'size_system')) { + $item->addChild('SIZE_SYSTEM', $attributeValue); + } else { + $item->addChild('SIZE_SYSTEM', 'INT'); + } } if ($attributeValue = $this->getAttributeValue($product, 'ean')) { @@ -355,7 +355,6 @@ public function getProductsCollection(): \Magento\Catalog\Model\ResourceModel\Pr $collection = $this->productCollection->create(); $collection->addAttributeToSelect('*')->setStore($this->store); $collection->addAttributeToFilter('status', ['in' => $this->productStatus->getVisibleStatusIds()]); - $collection->addAttributeToFilter('visibility', ['in' => $this->productVisibility->getVisibleInSiteIds()]); $collection->addAttributeToFilter('is_saleable', ['eq' => 1]); return $collection; @@ -404,7 +403,7 @@ private function getParentProductId(int $childProductId): int */ private function getProduct(bool $parent = true): ProductInterface { - if ($parent && $parentProductId = $this->getParentProductId($this->product->getId())) { + if ($parent && $parentProductId = $this->getParentProductId((int) $this->product->getId())) { try { $parentProduct = $this->productRepository->getById($parentProductId, false, $this->store->getId()); if (in_array($parentProduct->getStatus(), $this->productStatus->getVisibleStatusIds())