Also, please share the solution with Magento Community via social media.
Check out the below method to do so.
Equipping Magento 2 store with warehouse management as well as inventory management is one of the most crucial tasks for store owners. If you have more than one warehouse under your control, it is necessary to control all data in the inventory and get that data whenever you need it.
Any doubts? Do mention them in the Comments section below.
Method to Get Stock ID of Particular Website in Magento 2
* Class GetStockIdForWebsite
class GetStockIdForWebsite extends AbstractHelper
* @var GetAssignedStockIdForWebsite
* GetStockIdForWebsite constructor.
* @param Context $context
* @param GetAssignedStockIdForWebsite $getAssignedStockIdForWebsite
public function __construct(Context $context, GetAssignedStockIdForWebsite $getAssignedStockIdForWebsite)
$this->getAssignedStockIdForWebsite = $getAssignedStockIdForWebsite;
* @param $websiteCode
* @return int|null
public function getStockIdForWebsite($websiteCode)
In order to work with inventory among multiple warehouses easily, generate inventory-related reports, and manage stock effectively, one often needs to get stock id of particular website in Magento 2.
Never miss Magento tips, tricks, tutorials, and news.
Magento 2 multi-stock inventory makes the control of inventory for single or multiple sources and sales channels possible!
Something went wrong.
Use the below code in your helper file.
Get Weekly Updates
I would be glad to help you out.
Thank you for subscribing.