Skip to content

Commit

Permalink
MAGETWO-47431: [GITHUB] Some bug in $product->load($id) method for so…
Browse files Browse the repository at this point in the history
…me products #2800
  • Loading branch information
Michail Slabko committed Jan 18, 2016
1 parent a6e587f commit a831bd1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
6 changes: 3 additions & 3 deletions app/code/Magento/CatalogInventory/Helper/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public function __construct(
* Assign stock status information to product
*
* @param Product $product
* @param int $stockStatus
* @param int $status
* @return void
*/
public function assignStatusToProduct(Product $product, $stockStatus = null)
public function assignStatusToProduct(Product $product, $status = null)
{
if ($stockStatus === null) {
if ($status === null) {
$websiteId = $product->getStore()->getWebsiteId();
$stockStatus = $this->stockRegistryProvider->getStockStatus($product->getId(), $websiteId);
$status = $stockStatus->getStockStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public function execute(EventObserver $observer)
{
$product = $observer->getEvent()->getProduct();
if ($product instanceof \Magento\Catalog\Model\Product) {
$this->stockHelper->assignStatusToProduct(
$product,
$product->getStockStatus()
);
$this->stockHelper->assignStatusToProduct($product);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,17 @@ protected function setUp()

public function testAddInventoryData()
{
$stockStatus = true;

$product = $this->getMockBuilder('Magento\Catalog\Model\Product')
->disableOriginalConstructor()
->setMethods(['getStockStatus'])
->getMock();

$product->expects($this->once())
->method('getStockStatus')
->will($this->returnValue($stockStatus));

$this->event->expects($this->once())
->method('getProduct')
->will($this->returnValue($product));

$this->stockHelper->expects($this->once())
->method('assignStatusToProduct')
->with($product, $stockStatus)
->with($product)
->will($this->returnSelf());

$this->observer->execute($this->eventObserver);
Expand Down

0 comments on commit a831bd1

Please sign in to comment.