I need, on website save, get the inventory with the current website ID.
Ad I'm trying to get the CatalogInventory Stock Collection in an Observer, but it finish with the error:
Configuration array must have a key for 'dbname' that names the database instance
My Code is:
public function execute(\Magento\Framework\Event\Observer $observer)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$stockCollection = $objectManager->create('\Magento\CatalogInventory\Model\ResourceModel\Stock\Collection');
}
The event is: website_save_after
What is wrong with this?
I used this example: Magento 2 Get product collection