Skip to content

Commit

Permalink
adding crash logging to multi source inventory setting sync (#632)
Browse files Browse the repository at this point in the history
* adding crash logging to multi source inventory setting sync

* Changing get store id function to match strategy found elsewhere in code
  • Loading branch information
sol-loup authored Feb 9, 2024
1 parent 3368f04 commit 0be9248
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -81,6 +82,11 @@ class MultiSourceInventory extends InventoryRequirements implements InventoryInt
*/
private $stockItemCriteriaInterfaceFactory;

/**
* @var FBEHelper
*/
private FBEHelper $fbeHelper;

/**
* @param IsProductSalableInterface $isProductSalableInterface
* @param GetProductSalableQtyInterface $getProductSalableQtyInterface
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -106,6 +114,7 @@ public function __construct(
$this->getStockItemConfiguration = $getStockItemConfiguration;
$this->stockItemRepository = $stockItemRepository;
$this->stockItemCriteriaInterfaceFactory = $stockItemCriteriaInterfaceFactory;
$this->fbeHelper = $fbeHelper;
}

/**
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 0be9248

Please sign in to comment.