File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
app/code/Magento/Downloadable Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -164,10 +164,11 @@ public function getLinks($product)
164
164
*/
165
165
public function hasLinks ($ product )
166
166
{
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 );
169
170
}
170
- return count ( $ this -> getLinks ( $ product )) > 0 ;
171
+ return $ hasLinks ;
171
172
}
172
173
173
174
/**
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ protected function setUp()
83
83
'getDownloadableData ' ,
84
84
'setTypeHasOptions ' ,
85
85
'setLinksExist ' ,
86
+ 'getDownloadableLinks ' ,
86
87
'__wakeup ' ,
87
88
],
88
89
[],
@@ -144,4 +145,12 @@ public function testBeforeSave()
144
145
{
145
146
$ this ->target ->beforeSave ($ this ->product );
146
147
}
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
+ }
147
156
}
You can’t perform that action at this time.
0 commit comments