Skip to content

Commit

Permalink
IA-849 (#37)
Browse files Browse the repository at this point in the history
Co-authored-by: Tamás Perencz <tamas.perencz@itgcommerce.com>
Co-authored-by: Nikolay Dimitrov <dimitrov.nikolay@emarsys.com>
  • Loading branch information
3 people authored Apr 12, 2023
1 parent 54a0b98 commit e86b602
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 71 deletions.
4 changes: 3 additions & 1 deletion Events/CustomerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ private function handleConfirmation(Subscriber $subscriber, string $type, callab
$subscriber->getId(),
$this->getDataFromSubscription($subscriber, $websiteId)
);
} catch (Exception $e) {} //@codingStandardsIgnoreLine
} catch (Exception $e) {
$marketingEventsEnabled = true;
}

if ($magentoSendEmailEnabled) {
return $proceed($subscriber);
Expand Down
32 changes: 0 additions & 32 deletions Helper/Inventory.php

This file was deleted.

11 changes: 3 additions & 8 deletions Model/Api/InventoryApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Emartech\Emarsys\Api\Data\InventoryItemInterfaceFactory;
use Emartech\Emarsys\Api\Data\InventoryItemItemInterfaceFactory;
use Emartech\Emarsys\Api\InventoryApiInterface;
use Emartech\Emarsys\Helper\Inventory as InventoryHelper;
use Magento\Framework\Model\ResourceModel\Iterator;
use Magento\Inventory\Model\ResourceModel\SourceItem\Collection as SourceItemCollection;
use Magento\Inventory\Model\ResourceModel\SourceItem\CollectionFactory as SourceItemCollectionFactory;
Expand Down Expand Up @@ -62,20 +61,20 @@ class InventoryApi implements InventoryApiInterface
/**
* InventoryApi constructor.
*
* @param InventoryHelper $inventoryHelper
* @param SourceItemCollectionFactory $sourceItemCollectionFactory
* @param InventoryApiResponseInterfaceFactory $inventoryApiResponseFactory
* @param InventoryItemInterfaceFactory $inventoryItemInterfaceFactory
* @param InventoryItemItemInterfaceFactory $inventoryItemItemFactory
* @param Iterator $iterator
*/
public function __construct(
InventoryHelper $inventoryHelper,
SourceItemCollectionFactory $sourceItemCollectionFactory,
InventoryApiResponseInterfaceFactory $inventoryApiResponseFactory,
InventoryItemInterfaceFactory $inventoryItemInterfaceFactory,
InventoryItemItemInterfaceFactory $inventoryItemItemFactory,
Iterator $iterator
) {
$this->sourceItemCollectionFactory = $inventoryHelper->getSourceItemCollectionFactory();
$this->sourceItemCollectionFactory = $sourceItemCollectionFactory;
$this->inventoryApiResponseFactory = $inventoryApiResponseFactory;
$this->inventoryItemFactory = $inventoryItemInterfaceFactory;
$this->inventoryItemItemFactory = $inventoryItemItemFactory;
Expand All @@ -94,10 +93,6 @@ public function getList(array $sku): InventoryApiResponseInterface
/** @var InventoryApiResponseInterface $response */
$response = $this->inventoryApiResponseFactory->create();

if (null === $this->sourceItemCollectionFactory) {
return $response->setItems([]);
}

$this
->initCollection()
->filterSKUs($sku)
Expand Down
7 changes: 4 additions & 3 deletions Model/Data/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ public function isEnabledForStore(string $key, int $storeId = null): bool
}
}
}
} catch (Exception $e) { } //@codingStandardsIgnoreLine

return false;
return false;
} catch (Exception $e) {
return false;
}
}

/**
Expand Down
15 changes: 10 additions & 5 deletions Model/ResourceModel/Api/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,16 @@ public function getAttributeData(
)
->addFieldToFilter('attribute_code', ['in' => $attributeCodes]);

$failedSources = [];

/** @var Attribute $customerAttribute */
foreach ($customerAttributeCollection as $customerAttribute) {
if ($sourceModel = $customerAttribute->getSourceModel()) {
try {
$sourceModels[$customerAttribute->getAttributeCode()] = $customerAttribute->getSource();
} catch (\Exception $e) {} // @codingStandardsIgnoreLine
} catch (\Exception $e) {
$failedSources[] = $customerAttribute->getSource();
}
}

$attributeTable = $customerAttribute->getBackendTable();
Expand Down Expand Up @@ -409,7 +413,7 @@ private function getAttributeTableFieldItems(
$unionQuery = $this->_resource
->getConnection()
->select()
->union($attributeQueries, \Zend_Db_Select::SQL_UNION_ALL); // @codingStandardsIgnoreLine
->union($attributeQueries, 'UNION ALL');
$this->iterator->walk(
(string) $unionQuery,
[[$this, 'handleAttributeDataTable']],
Expand All @@ -419,9 +423,10 @@ private function getAttributeTableFieldItems(
$this->_resource->getConnection()
);
}
} catch (\Exception $e) {} // @codingStandardsIgnoreLine

return $this;
return $this;
} catch (\Exception $e) {
return $this;
}
}

/**
Expand Down
15 changes: 10 additions & 5 deletions Model/ResourceModel/Api/CustomerAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,17 @@ public function getAttributeData(
->addFieldToFilter('entity_type_id', ['eq' => self::CUSTOMER_ADDRESS_ENTITY_TYPE_ID])
->addFieldToFilter('attribute_code', ['in' => $attributeCodes]);

$failedSources = [];

/** @var Attribute $customerAddressAttribute */
foreach ($customerAddressAttributeCollection as $customerAddressAttribute) {
if ($sourceModel = $customerAddressAttribute->getSourceModel()) {
try {
$sourceModels[$customerAddressAttribute->getAttributeCode()] =
$customerAddressAttribute->getSource();
} catch (\Exception $e) {} // @codingStandardsIgnoreLine
} catch (\Exception $e) {
$failedSources[] = $customerAddressAttribute->getSource();
}
}

$attributeTable = $customerAddressAttribute->getBackendTable();
Expand Down Expand Up @@ -304,7 +308,7 @@ private function getAttributeTableFieldItems(
$unionQuery = $this->_resource
->getConnection()
->select()
->union($attributeQueries, \Zend_Db_Select::SQL_UNION_ALL); // @codingStandardsIgnoreLine
->union($attributeQueries, 'UNION ALL');

$this->iterator->walk(
(string) $unionQuery,
Expand All @@ -315,9 +319,10 @@ private function getAttributeTableFieldItems(
$this->_resource->getConnection()
);
}
} catch (\Exception $e) {} // @codingStandardsIgnoreLine

return $this;
return $this;
} catch (\Exception $e) {
return $this;
}
}

/**
Expand Down
29 changes: 14 additions & 15 deletions Model/ResourceModel/Api/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class Product extends ProductResourceModel
* @param Iterator $iterator
* @param LinkField $linkFieldHelper
* @param DataSourceHelper $dataSourceHelper
* @param PriceTableResolver $priceTableResolver
* @param DimensionFactory $dimensionFactory
* @param array $data
*
* @throws Exception
Expand All @@ -167,6 +169,8 @@ public function __construct(
Iterator $iterator,
LinkField $linkFieldHelper,
DataSourceHelper $dataSourceHelper,
PriceTableResolver $priceTableResolver,
DimensionFactory $dimensionFactory,
array $data = []
) {
$this->iterator = $iterator;
Expand All @@ -175,17 +179,8 @@ public function __construct(
$this->linkField = $this->linkFieldHelper->getEntityLinkField(ProductInterface::class);

$this->dataSourceHelper = $dataSourceHelper;

if (class_exists(PriceTableResolver::class)) {
// @codingStandardsIgnoreStart
$this->priceTableResolver = ObjectManager::getInstance()->get(PriceTableResolver::class);
// @codingStandardsIgnoreEnd
}
if (class_exists(Dimension::class)) {
// @codingStandardsIgnoreStart
$this->dimensionFactory = ObjectManager::getInstance()->get(DimensionFactory::class);
// @codingStandardsIgnoreEnd
}
$this->priceTableResolver = $priceTableResolver;
$this->dimensionFactory = $dimensionFactory;

parent::__construct(
$context,
Expand Down Expand Up @@ -503,13 +498,17 @@ public function getAttributeData(
->addFieldToFilter('entity_type_id', ['eq' => self::PRODUCT_ENTITY_TYPE_ID])
->addFieldToFilter('attribute_code', ['in' => $attributeCodes]);

$failedSources = [];

/** @var ProductAttribute $productAttribute */
foreach ($productAttributeCollection as $productAttribute) {
if ($sourceModel = $productAttribute->getSourceModel()) {
try {
$sourceModels[$productAttribute->getAttributeCode()] =
$productAttribute->getSource();
} catch (Exception $e) {} // @codingStandardsIgnoreLine
} catch (Exception $e) {
$failedSources[] = $productAttribute->getSource();
}
}

$attributeTable = $productAttribute->getBackendTable();
Expand Down Expand Up @@ -679,10 +678,10 @@ private function getAttributeTableFieldItems(
$this->_resource->getConnection()
);
}
} catch (Exception $e) { // @codingStandardsIgnoreLine
return $this;
} catch (Exception $e) {
return $this;
}

return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"php": ">7.0.1"
},
"type": "magento2-module",
"version": "2.0.6",
"version": "2.0.7",
"autoload": {
"files": [
"registration.php"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Emartech_Emarsys" setup_version="2.0.6">
<module name="Emartech_Emarsys" setup_version="2.0.7">
<sequence>
<module name="Magento_Sales" />
</sequence>
Expand Down

0 comments on commit e86b602

Please sign in to comment.