diff --git a/CHANGELOG.md b/CHANGELOG.md index 1daebbf..b751b44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGE LOG +## 2.4.3 +- PIM-414 Bugfix | Fix PHPStan errors +--- ## 2.4.2 - PIM-351 Bugfix | Fix db_schema.xml to be valid against schema.xsd --- diff --git a/Model/Export/Product.php b/Model/Export/Product.php index 2f0d185..6a37e7f 100644 --- a/Model/Export/Product.php +++ b/Model/Export/Product.php @@ -330,7 +330,6 @@ private function _prepareAttributes($productIds) */ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection\AbstractCollection $collection) { - foreach ($this->getAttributeCollection() as $attribute) { //$this->filterAttributeCollection() $attrCode = $attribute->getAttributeCode(); $exportAttrCodes = $this->_getExportAttrCodes(); @@ -339,6 +338,8 @@ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection $collection->addAttributeToSelect($attrCode); } } + + return $collection; } /** diff --git a/Model/Import/Product/BundleManagement.php b/Model/Import/Product/BundleManagement.php index c04290e..84299fb 100644 --- a/Model/Import/Product/BundleManagement.php +++ b/Model/Import/Product/BundleManagement.php @@ -30,6 +30,8 @@ class BundleManagement extends AbstractManagement implements \Cobby\Connector\Ap 'sku_type', 'shipment_type' ); + + private $prodAttrColFac; /** * BundleManagement constructor. diff --git a/Model/Import/Product/StockManagement.php b/Model/Import/Product/StockManagement.php index 822ac11..3f89ba8 100644 --- a/Model/Import/Product/StockManagement.php +++ b/Model/Import/Product/StockManagement.php @@ -220,76 +220,4 @@ public function import($rows) return $result; } - - /** - * Stock item saving. - * - * @return $this - */ - protected function _saveStockItem() - { - $indexer = $this->indexerRegistry->get('catalog_product_category'); - /** @var $stockResource \Magento\CatalogInventory\Model\ResourceModel\Stock\Item */ - $stockResource = $this->_stockResItemFac->create(); - $entityTable = $stockResource->getMainTable(); - while ($bunch = $this->_dataSourceModel->getNextBunch()) { - $stockData = []; - $productIdsToReindex = []; - // Format bunch to stock data rows - foreach ($bunch as $rowNum => $rowData) { - if (!$this->isRowAllowedToImport($rowData, $rowNum)) { - continue; - } - - $row = []; - $row['product_id'] = $this->skuProcessor->getNewSku($rowData[self::COL_SKU])['entity_id']; - $productIdsToReindex[] = $row['product_id']; - - $row['website_id'] = $this->stockConfiguration->getDefaultScopeId(); - $row['stock_id'] = $this->stockRegistry->getStock($row['website_id'])->getStockId(); - - $stockItemDo = $this->stockRegistry->getStockItem($row['product_id'], $row['website_id']); - $existStockData = $stockItemDo->getData(); - - $row = array_merge( - $this->defaultStockData, - array_intersect_key($existStockData, $this->defaultStockData), - array_intersect_key($rowData, $this->defaultStockData), - $row - ); - - - - if ($this->stockConfiguration->isQty( - $this->skuProcessor->getNewSku($rowData[self::COL_SKU])['type_id'] - )) { - $stockItemDo->setData($row); - $row['is_in_stock'] = $this->stockStateProvider->verifyStock($stockItemDo); - if ($this->stockStateProvider->verifyNotification($stockItemDo)) { - $row['low_stock_date'] = $this->dateTime->gmDate( - 'Y-m-d H:i:s', - (new \DateTime())->getTimestamp() - ); - } - $row['stock_status_changed_auto'] = - (int) !$this->stockStateProvider->verifyStock($stockItemDo); - } else { - $row['qty'] = 0; - } - if (!isset($stockData[$rowData[self::COL_SKU]])) { - $stockData[$rowData[self::COL_SKU]] = $row; - } - } - - // Insert rows - if (!empty($stockData)) { - $this->_connection->insertOnDuplicate($entityTable, array_values($stockData)); - } - - if ($productIdsToReindex) { - $indexer->reindexList($productIdsToReindex); - } - } - return $this; - } } diff --git a/Model/Import/Product/UrlManagement.php b/Model/Import/Product/UrlManagement.php index 0f23888..d26fc51 100644 --- a/Model/Import/Product/UrlManagement.php +++ b/Model/Import/Product/UrlManagement.php @@ -115,6 +115,10 @@ class UrlManagement extends AbstractManagement implements \Cobby\Connector\Api\I protected $urlRewriteFactory; protected $newUrls; + /** + * @var \Cobby\Connector\Helper\Settings + */ + private $settings; /** * constructor. @@ -442,39 +446,39 @@ protected function currentUrlRewritesRegenerate() return $urlRewrites; } - /** - * @param UrlRewrite $url - * @param Category $category - * @return array - */ - protected function generateForAutogenerated($url, $category) - { - $storeId = $url->getStoreId(); - $productId = $url->getEntityId(); - if (isset($this->products[$productId][$storeId])) { - $product = $this->products[$productId][$storeId]; - if (!$product->getData('save_rewrites_history')) { - return []; - } - $targetPath = $this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId, $category); - if ($url->getRequestPath() === $targetPath) { - return []; - } - return [ - $this->urlRewriteFactory->create() - ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) - ->setEntityId($productId) - ->setRequestPath($url->getRequestPath()) - ->setTargetPath($targetPath) - ->setRedirectType(OptionProvider::PERMANENT) - ->setStoreId($storeId) - ->setDescription($url->getDescription()) - ->setIsAutogenerated(0) - ->setMetadata($url->getMetadata()) - ]; - } - return []; - } +// /** +// * @param UrlRewrite $url +// * @param Category $category +// * @return array +// */ +// protected function generateForAutogenerated($url, $category) +// { +// $storeId = $url->getStoreId(); +// $productId = $url->getEntityId(); +// if (isset($this->products[$productId][$storeId])) { +// $product = $this->products[$productId][$storeId]; +// if (!$product->getData('save_rewrites_history')) { +// return []; +// } +// $targetPath = $this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId, $category); +// if ($url->getRequestPath() === $targetPath) { +// return []; +// } +// return [ +// $this->urlRewriteFactory->create() +// ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) +// ->setEntityId($productId) +// ->setRequestPath($url->getRequestPath()) +// ->setTargetPath($targetPath) +// ->setRedirectType(OptionProvider::PERMANENT) +// ->setStoreId($storeId) +// ->setDescription($url->getDescription()) +// ->setIsAutogenerated(0) +// ->setMetadata($url->getMetadata()) +// ]; +// } +// return []; +// } /** * @param UrlRewrite $url diff --git a/Model/Queue.php b/Model/Queue.php index e75d47e..7166753 100644 --- a/Model/Queue.php +++ b/Model/Queue.php @@ -85,7 +85,9 @@ public function beforeSave() $result = $this->getCurrentContext(); $this->addData($result); - parent::beforeSave(); + parent::beforeSave(); + + return $this; } private function getCurrentContext() diff --git a/composer.json b/composer.json index 2c468c2..403c025 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name" : "cobbyio/cobby-connector-magento2", "description" : "This extension for Magento 2 provides a direct integration of the cobby management methods to your Magento 2 shop.", - "version" : "2.4.2", + "version" : "2.4.3", "type" : "magento2-module", "require": { "magento/framework": "^102.0|^103.0|^104.0",