261 alert functionality#366
261 alert functionality#366chrom wants to merge 5 commits intomagento:261_alert_functionalityfrom chrom:261_alert_functionality
Conversation
…61_alert_functionality # Conflicts: # app/code/Magento/ProductAlert/Model/Observer.php
| * @var array | ||
| */ | ||
| protected $_websites; | ||
| private $websites; |
There was a problem hiding this comment.
This is legacy class, we need to follow backward compatibility
So need to revert all changes in this class
We change the only if ($this->productIsSalable->isSalable condition
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\InventorySalesAlert\Api; |
There was a problem hiding this comment.
More related name is InventoryProductAlert (now we have ProductAlert module but not SalesAlert)
NAmespace should be Magento\ProductAlert\Model\...
| * | ||
| * @api | ||
| */ | ||
| interface ProductIsSalableInterface |
There was a problem hiding this comment.
This interface should be placed in current ProductAlert module and should be part of current implementation
ProductAlert module must work without new InventoryProductAlert
| * @param \Magento\InventoryApi\Api\IsProductInStockInterface $stockItem | ||
| */ | ||
| public function __construct( | ||
| StockResolver $stockResolver = null, |
There was a problem hiding this comment.
It is new code, so parameters should be not null (without '= null')
| StockResolver $stockResolver = null, | ||
| IsProductInStockInterface $stockItem = null | ||
| ) { | ||
| $this->stockItem = $stockItem ?: ObjectManager::getInstance()->get(IsProductInStock::class); |
There was a problem hiding this comment.
This trick is needed only for backward compatibility, but i this case it is new code
| <?xml version="1.0"?> | ||
| <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
| <module name="Magento_InventorySalesAlert" setup_version="0.1.0"> |
| /** | ||
| * Is product salable | ||
| * | ||
| * Used fully qualified namespaces in annotations for proper work of WebApi request parser |
There was a problem hiding this comment.
Remove this comments because this interface is not part of Web-API
| { | ||
| /** | ||
| * @param ProductInterface $product | ||
| * @param string $websiteCode |
There was a problem hiding this comment.
Pls use Magento code style for formatting
| */ | ||
| public function isSalable( | ||
| ProductInterface $product, | ||
| string $websiteCode, |
There was a problem hiding this comment.
The second parameter should be only $website
This is related to current implementation
| */ | ||
| --> | ||
| <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
| <preference for="Magento\InventorySalesAlert\Api\ProductIsSalableInterface" type="Magento\InventorySalesAlert\Model\ProductIsSalable"/> |
There was a problem hiding this comment.
Default implementation (related to current code with calling $product->isSalable()) of ProductIsSalableInterface is missed
No description provided.