Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dimajanzen committed Jan 16, 2023
2 parents 62ff03d + 2f7da13 commit af655db
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 108 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
---
Expand Down
3 changes: 2 additions & 1 deletion Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -339,6 +338,8 @@ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection
$collection->addAttributeToSelect($attrCode);
}
}

return $collection;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Model/Import/Product/BundleManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class BundleManagement extends AbstractManagement implements \Cobby\Connector\Ap
'sku_type',
'shipment_type'
);

private $prodAttrColFac;

/**
* BundleManagement constructor.
Expand Down
72 changes: 0 additions & 72 deletions Model/Import/Product/StockManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
70 changes: 37 additions & 33 deletions Model/Import/Product/UrlManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Model/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public function beforeSave()
$result = $this->getCurrentContext();
$this->addData($result);

parent::beforeSave();
parent::beforeSave();

return $this;
}

private function getCurrentContext()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit af655db

Please sign in to comment.