Magento 2 multi-stock inventory makes the control of inventory for single or multiple sources and sales channels possible!
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.
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.
Check out the below method to do so.
Method to Get Stock ID of Particular Website in Magento 2
Use the below code in your helper file.
* 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)
Any doubts? Do mention them in the Comments section below.
I would be glad to help you out.
Also, please share the solution with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.