From 0be92481ddbdf5440803f1f7472e561b6c15ce04 Mon Sep 17 00:00:00 2001 From: Paul Kang Date: Fri, 9 Feb 2024 09:24:42 -0800 Subject: [PATCH] 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 --- .../Feed/Builder/MultiSourceInventory.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/code/Meta/Catalog/Model/Product/Feed/Builder/MultiSourceInventory.php b/app/code/Meta/Catalog/Model/Product/Feed/Builder/MultiSourceInventory.php index d2716ca7..fe1be119 100644 --- a/app/code/Meta/Catalog/Model/Product/Feed/Builder/MultiSourceInventory.php +++ b/app/code/Meta/Catalog/Model/Product/Feed/Builder/MultiSourceInventory.php @@ -28,6 +28,7 @@ use Magento\InventorySalesApi\Api\IsProductSalableInterface; use Magento\InventorySalesApi\Model\StockByWebsiteIdResolverInterface; use Meta\BusinessExtension\Model\System\Config as SystemConfig; +use Meta\BusinessExtension\Helper\FBEHelper; class MultiSourceInventory extends InventoryRequirements implements InventoryInterface { @@ -81,6 +82,11 @@ class MultiSourceInventory extends InventoryRequirements implements InventoryInt */ private $stockItemCriteriaInterfaceFactory; + /** + * @var FBEHelper + */ + private FBEHelper $fbeHelper; + /** * @param IsProductSalableInterface $isProductSalableInterface * @param GetProductSalableQtyInterface $getProductSalableQtyInterface @@ -89,6 +95,7 @@ class MultiSourceInventory extends InventoryRequirements implements InventoryInt * @param GetStockItemConfigurationInterface $getStockItemConfiguration * @param StockItemRepositoryInterface $stockItemRepository * @param StockItemCriteriaInterfaceFactory $stockItemCriteriaInterfaceFactory + * @param FBEHelper $fbeHelper */ public function __construct( IsProductSalableInterface $isProductSalableInterface, @@ -97,7 +104,8 @@ public function __construct( StockByWebsiteIdResolverInterface $stockByWebsiteIdResolver, GetStockItemConfigurationInterface $getStockItemConfiguration, StockItemRepositoryInterface $stockItemRepository, - StockItemCriteriaInterfaceFactory $stockItemCriteriaInterfaceFactory + StockItemCriteriaInterfaceFactory $stockItemCriteriaInterfaceFactory, + FBEHelper $fbeHelper ) { $this->isProductSalableInterface = $isProductSalableInterface; $this->getProductSalableQtyInterface = $getProductSalableQtyInterface; @@ -106,6 +114,7 @@ public function __construct( $this->getStockItemConfiguration = $getStockItemConfiguration; $this->stockItemRepository = $stockItemRepository; $this->stockItemCriteriaInterfaceFactory = $stockItemCriteriaInterfaceFactory; + $this->fbeHelper = $fbeHelper; } /** @@ -159,7 +168,16 @@ public function isStockManagedForProduct(): bool $stockItemConfiguration = $this->getStockItemConfiguration->execute($this->product->getSku(), $stockId); return $stockItemConfiguration->isManageStock(); } catch (\Throwable $e) { + $this->fbeHelper->logExceptionImmediatelytoMeta( + $e, + [ + 'store_id' => $this->product->getStoreId(), + 'event' => 'catalog_sync', + 'event_type' => 'multi_source_inventory_sync_error' + ] + ); try { + // fallback to single inventory mechanism in case of error $criteria = $this->stockItemCriteriaInterfaceFactory->create(); $criteria->setProductsFilter($this->product->getId());