Skip to content

Commit 619ebcd

Browse files
committed
MAGETWO-52030: Downloadable product show as out of stock in category page
1 parent 7a04197 commit 619ebcd

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

app/code/Magento/Downloadable/Model/Product/Type.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@ public function getLinks($product)
164164
*/
165165
public function hasLinks($product)
166166
{
167-
if ($product->hasData('links_exist')) {
168-
return $product->getData('links_exist');
167+
$hasLinks = $product->getData('links_exist');
168+
if (null === $hasLinks) {
169+
$hasLinks = (count($this->getLinks($product)) > 0);
169170
}
170-
return count($this->getLinks($product)) > 0;
171+
return $hasLinks;
171172
}
172173

173174
/**

app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ protected function setUp()
8383
'getDownloadableData',
8484
'setTypeHasOptions',
8585
'setLinksExist',
86+
'getDownloadableLinks',
8687
'__wakeup',
8788
],
8889
[],
@@ -144,4 +145,12 @@ public function testBeforeSave()
144145
{
145146
$this->target->beforeSave($this->product);
146147
}
148+
149+
public function testHasLinks()
150+
{
151+
$this->product->expects($this->exactly(2))
152+
->method('getDownloadableLinks')
153+
->willReturn(['link1', 'link2']);
154+
$this->assertTrue($this->target->hasLinks($this->product));
155+
}
147156
}

0 commit comments

Comments
 (0)