Skip to content

Commit 0be9248

Browse files
authored
adding crash logging to multi source inventory setting sync (#632)
* adding crash logging to multi source inventory setting sync * Changing get store id function to match strategy found elsewhere in code
1 parent 3368f04 commit 0be9248

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

app/code/Meta/Catalog/Model/Product/Feed/Builder/MultiSourceInventory.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Magento\InventorySalesApi\Api\IsProductSalableInterface;
2929
use Magento\InventorySalesApi\Model\StockByWebsiteIdResolverInterface;
3030
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
31+
use Meta\BusinessExtension\Helper\FBEHelper;
3132

3233
class MultiSourceInventory extends InventoryRequirements implements InventoryInterface
3334
{
@@ -81,6 +82,11 @@ class MultiSourceInventory extends InventoryRequirements implements InventoryInt
8182
*/
8283
private $stockItemCriteriaInterfaceFactory;
8384

85+
/**
86+
* @var FBEHelper
87+
*/
88+
private FBEHelper $fbeHelper;
89+
8490
/**
8591
* @param IsProductSalableInterface $isProductSalableInterface
8692
* @param GetProductSalableQtyInterface $getProductSalableQtyInterface
@@ -89,6 +95,7 @@ class MultiSourceInventory extends InventoryRequirements implements InventoryInt
8995
* @param GetStockItemConfigurationInterface $getStockItemConfiguration
9096
* @param StockItemRepositoryInterface $stockItemRepository
9197
* @param StockItemCriteriaInterfaceFactory $stockItemCriteriaInterfaceFactory
98+
* @param FBEHelper $fbeHelper
9299
*/
93100
public function __construct(
94101
IsProductSalableInterface $isProductSalableInterface,
@@ -97,7 +104,8 @@ public function __construct(
97104
StockByWebsiteIdResolverInterface $stockByWebsiteIdResolver,
98105
GetStockItemConfigurationInterface $getStockItemConfiguration,
99106
StockItemRepositoryInterface $stockItemRepository,
100-
StockItemCriteriaInterfaceFactory $stockItemCriteriaInterfaceFactory
107+
StockItemCriteriaInterfaceFactory $stockItemCriteriaInterfaceFactory,
108+
FBEHelper $fbeHelper
101109
) {
102110
$this->isProductSalableInterface = $isProductSalableInterface;
103111
$this->getProductSalableQtyInterface = $getProductSalableQtyInterface;
@@ -106,6 +114,7 @@ public function __construct(
106114
$this->getStockItemConfiguration = $getStockItemConfiguration;
107115
$this->stockItemRepository = $stockItemRepository;
108116
$this->stockItemCriteriaInterfaceFactory = $stockItemCriteriaInterfaceFactory;
117+
$this->fbeHelper = $fbeHelper;
109118
}
110119

111120
/**
@@ -159,7 +168,16 @@ public function isStockManagedForProduct(): bool
159168
$stockItemConfiguration = $this->getStockItemConfiguration->execute($this->product->getSku(), $stockId);
160169
return $stockItemConfiguration->isManageStock();
161170
} catch (\Throwable $e) {
171+
$this->fbeHelper->logExceptionImmediatelytoMeta(
172+
$e,
173+
[
174+
'store_id' => $this->product->getStoreId(),
175+
'event' => 'catalog_sync',
176+
'event_type' => 'multi_source_inventory_sync_error'
177+
]
178+
);
162179
try {
180+
163181
// fallback to single inventory mechanism in case of error
164182
$criteria = $this->stockItemCriteriaInterfaceFactory->create();
165183
$criteria->setProductsFilter($this->product->getId());

0 commit comments

Comments
 (0)