Skip to content

Commit e86b602

Browse files
ptomitperenczNikolay Dimitrov
authored
IA-849 (#37)
Co-authored-by: Tamás Perencz <[email protected]> Co-authored-by: Nikolay Dimitrov <[email protected]>
1 parent 54a0b98 commit e86b602

File tree

9 files changed

+46
-71
lines changed

9 files changed

+46
-71
lines changed

Events/CustomerPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ private function handleConfirmation(Subscriber $subscriber, string $type, callab
456456
$subscriber->getId(),
457457
$this->getDataFromSubscription($subscriber, $websiteId)
458458
);
459-
} catch (Exception $e) {} //@codingStandardsIgnoreLine
459+
} catch (Exception $e) {
460+
$marketingEventsEnabled = true;
461+
}
460462

461463
if ($magentoSendEmailEnabled) {
462464
return $proceed($subscriber);

Helper/Inventory.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

Model/Api/InventoryApi.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Emartech\Emarsys\Api\Data\InventoryItemInterfaceFactory;
1313
use Emartech\Emarsys\Api\Data\InventoryItemItemInterfaceFactory;
1414
use Emartech\Emarsys\Api\InventoryApiInterface;
15-
use Emartech\Emarsys\Helper\Inventory as InventoryHelper;
1615
use Magento\Framework\Model\ResourceModel\Iterator;
1716
use Magento\Inventory\Model\ResourceModel\SourceItem\Collection as SourceItemCollection;
1817
use Magento\Inventory\Model\ResourceModel\SourceItem\CollectionFactory as SourceItemCollectionFactory;
@@ -62,20 +61,20 @@ class InventoryApi implements InventoryApiInterface
6261
/**
6362
* InventoryApi constructor.
6463
*
65-
* @param InventoryHelper $inventoryHelper
64+
* @param SourceItemCollectionFactory $sourceItemCollectionFactory
6665
* @param InventoryApiResponseInterfaceFactory $inventoryApiResponseFactory
6766
* @param InventoryItemInterfaceFactory $inventoryItemInterfaceFactory
6867
* @param InventoryItemItemInterfaceFactory $inventoryItemItemFactory
6968
* @param Iterator $iterator
7069
*/
7170
public function __construct(
72-
InventoryHelper $inventoryHelper,
71+
SourceItemCollectionFactory $sourceItemCollectionFactory,
7372
InventoryApiResponseInterfaceFactory $inventoryApiResponseFactory,
7473
InventoryItemInterfaceFactory $inventoryItemInterfaceFactory,
7574
InventoryItemItemInterfaceFactory $inventoryItemItemFactory,
7675
Iterator $iterator
7776
) {
78-
$this->sourceItemCollectionFactory = $inventoryHelper->getSourceItemCollectionFactory();
77+
$this->sourceItemCollectionFactory = $sourceItemCollectionFactory;
7978
$this->inventoryApiResponseFactory = $inventoryApiResponseFactory;
8079
$this->inventoryItemFactory = $inventoryItemInterfaceFactory;
8180
$this->inventoryItemItemFactory = $inventoryItemItemFactory;
@@ -94,10 +93,6 @@ public function getList(array $sku): InventoryApiResponseInterface
9493
/** @var InventoryApiResponseInterface $response */
9594
$response = $this->inventoryApiResponseFactory->create();
9695

97-
if (null === $this->sourceItemCollectionFactory) {
98-
return $response->setItems([]);
99-
}
100-
10196
$this
10297
->initCollection()
10398
->filterSKUs($sku)

Model/Data/Config.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,10 @@ public function isEnabledForStore(string $key, int $storeId = null): bool
342342
}
343343
}
344344
}
345-
} catch (Exception $e) { } //@codingStandardsIgnoreLine
346-
347-
return false;
345+
return false;
346+
} catch (Exception $e) {
347+
return false;
348+
}
348349
}
349350

350351
/**

Model/ResourceModel/Api/Customer.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,16 @@ public function getAttributeData(
235235
)
236236
->addFieldToFilter('attribute_code', ['in' => $attributeCodes]);
237237

238+
$failedSources = [];
239+
238240
/** @var Attribute $customerAttribute */
239241
foreach ($customerAttributeCollection as $customerAttribute) {
240242
if ($sourceModel = $customerAttribute->getSourceModel()) {
241243
try {
242244
$sourceModels[$customerAttribute->getAttributeCode()] = $customerAttribute->getSource();
243-
} catch (\Exception $e) {} // @codingStandardsIgnoreLine
245+
} catch (\Exception $e) {
246+
$failedSources[] = $customerAttribute->getSource();
247+
}
244248
}
245249

246250
$attributeTable = $customerAttribute->getBackendTable();
@@ -409,7 +413,7 @@ private function getAttributeTableFieldItems(
409413
$unionQuery = $this->_resource
410414
->getConnection()
411415
->select()
412-
->union($attributeQueries, \Zend_Db_Select::SQL_UNION_ALL); // @codingStandardsIgnoreLine
416+
->union($attributeQueries, 'UNION ALL');
413417
$this->iterator->walk(
414418
(string) $unionQuery,
415419
[[$this, 'handleAttributeDataTable']],
@@ -419,9 +423,10 @@ private function getAttributeTableFieldItems(
419423
$this->_resource->getConnection()
420424
);
421425
}
422-
} catch (\Exception $e) {} // @codingStandardsIgnoreLine
423-
424-
return $this;
426+
return $this;
427+
} catch (\Exception $e) {
428+
return $this;
429+
}
425430
}
426431

427432
/**

Model/ResourceModel/Api/CustomerAddress.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,17 @@ public function getAttributeData(
129129
->addFieldToFilter('entity_type_id', ['eq' => self::CUSTOMER_ADDRESS_ENTITY_TYPE_ID])
130130
->addFieldToFilter('attribute_code', ['in' => $attributeCodes]);
131131

132+
$failedSources = [];
133+
132134
/** @var Attribute $customerAddressAttribute */
133135
foreach ($customerAddressAttributeCollection as $customerAddressAttribute) {
134136
if ($sourceModel = $customerAddressAttribute->getSourceModel()) {
135137
try {
136138
$sourceModels[$customerAddressAttribute->getAttributeCode()] =
137139
$customerAddressAttribute->getSource();
138-
} catch (\Exception $e) {} // @codingStandardsIgnoreLine
140+
} catch (\Exception $e) {
141+
$failedSources[] = $customerAddressAttribute->getSource();
142+
}
139143
}
140144

141145
$attributeTable = $customerAddressAttribute->getBackendTable();
@@ -304,7 +308,7 @@ private function getAttributeTableFieldItems(
304308
$unionQuery = $this->_resource
305309
->getConnection()
306310
->select()
307-
->union($attributeQueries, \Zend_Db_Select::SQL_UNION_ALL); // @codingStandardsIgnoreLine
311+
->union($attributeQueries, 'UNION ALL');
308312

309313
$this->iterator->walk(
310314
(string) $unionQuery,
@@ -315,9 +319,10 @@ private function getAttributeTableFieldItems(
315319
$this->_resource->getConnection()
316320
);
317321
}
318-
} catch (\Exception $e) {} // @codingStandardsIgnoreLine
319-
320-
return $this;
322+
return $this;
323+
} catch (\Exception $e) {
324+
return $this;
325+
}
321326
}
322327

323328
/**

Model/ResourceModel/Api/Product.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class Product extends ProductResourceModel
149149
* @param Iterator $iterator
150150
* @param LinkField $linkFieldHelper
151151
* @param DataSourceHelper $dataSourceHelper
152+
* @param PriceTableResolver $priceTableResolver
153+
* @param DimensionFactory $dimensionFactory
152154
* @param array $data
153155
*
154156
* @throws Exception
@@ -167,6 +169,8 @@ public function __construct(
167169
Iterator $iterator,
168170
LinkField $linkFieldHelper,
169171
DataSourceHelper $dataSourceHelper,
172+
PriceTableResolver $priceTableResolver,
173+
DimensionFactory $dimensionFactory,
170174
array $data = []
171175
) {
172176
$this->iterator = $iterator;
@@ -175,17 +179,8 @@ public function __construct(
175179
$this->linkField = $this->linkFieldHelper->getEntityLinkField(ProductInterface::class);
176180

177181
$this->dataSourceHelper = $dataSourceHelper;
178-
179-
if (class_exists(PriceTableResolver::class)) {
180-
// @codingStandardsIgnoreStart
181-
$this->priceTableResolver = ObjectManager::getInstance()->get(PriceTableResolver::class);
182-
// @codingStandardsIgnoreEnd
183-
}
184-
if (class_exists(Dimension::class)) {
185-
// @codingStandardsIgnoreStart
186-
$this->dimensionFactory = ObjectManager::getInstance()->get(DimensionFactory::class);
187-
// @codingStandardsIgnoreEnd
188-
}
182+
$this->priceTableResolver = $priceTableResolver;
183+
$this->dimensionFactory = $dimensionFactory;
189184

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

501+
$failedSources = [];
502+
506503
/** @var ProductAttribute $productAttribute */
507504
foreach ($productAttributeCollection as $productAttribute) {
508505
if ($sourceModel = $productAttribute->getSourceModel()) {
509506
try {
510507
$sourceModels[$productAttribute->getAttributeCode()] =
511508
$productAttribute->getSource();
512-
} catch (Exception $e) {} // @codingStandardsIgnoreLine
509+
} catch (Exception $e) {
510+
$failedSources[] = $productAttribute->getSource();
511+
}
513512
}
514513

515514
$attributeTable = $productAttribute->getBackendTable();
@@ -679,10 +678,10 @@ private function getAttributeTableFieldItems(
679678
$this->_resource->getConnection()
680679
);
681680
}
682-
} catch (Exception $e) { // @codingStandardsIgnoreLine
681+
return $this;
682+
} catch (Exception $e) {
683+
return $this;
683684
}
684-
685-
return $this;
686685
}
687686

688687
/**

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"php": ">7.0.1"
77
},
88
"type": "magento2-module",
9-
"version": "2.0.6",
9+
"version": "2.0.7",
1010
"autoload": {
1111
"files": [
1212
"registration.php"

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22

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

0 commit comments

Comments
 (0)