Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_alert_customer.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
13 $productRepository = $objectManager->get(ProductRepositoryInterface::class);
14 $product = $productRepository->get('SKU-3');
15 
16 $stock = $objectManager->create(\Magento\ProductAlert\Model\Stock::class);
17 $stock->setCustomerId(1)
18  ->setProductId($product->getId())
19  ->setWebsiteId(1)
20  ->save();