本文整理汇总了PHP中Observer::addStockStatusToCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::addStockStatusToCollection方法的具体用法?PHP Observer::addStockStatusToCollection怎么用?PHP Observer::addStockStatusToCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Observer
的用法示例。
在下文中一共展示了Observer::addStockStatusToCollection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddInventoryDataToCollection
public function testAddInventoryDataToCollection()
{
$productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\Collection')->disableOriginalConstructor()->getMock();
$this->event->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection));
$this->stockHelper->expects($this->once())->method('addStockStatusToProducts')->with($productCollection)->will($this->returnSelf());
$this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
$this->assertEquals($this->observer, $this->observer->addStockStatusToCollection($this->eventObserver));
}
示例2: testAddStockStatusToCollectionRequireStockItems
public function testAddStockStatusToCollectionRequireStockItems()
{
$requireStockItems = true;
$productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\Collection')->disableOriginalConstructor()->setMethods(['hasFlag'])->getMock();
$this->event->expects($this->once())->method('getCollection')->will($this->returnValue($productCollection));
$productCollection->expects($this->once())->method('hasFlag')->with('require_stock_items')->will($this->returnValue($requireStockItems));
$stock = $this->getMockBuilder('Magento\\CatalogInventory\\Model\\Stock')->disableOriginalConstructor()->getMock();
$this->stockFactory->expects($this->once())->method('create')->will($this->returnValue($stock));
$stock->expects($this->once())->method('addItemsToProducts')->with($productCollection)->will($this->returnSelf());
$this->assertEquals($this->model, $this->model->addStockStatusToCollection($this->eventObserver));
}