View Issue Details

IDProjectCategoryView StatusLast Update
0006354OXID eShop (all versions)4.07. Source code, Testpublic2016-03-22 10:20
Status acknowledgedResolutionopen 
Product Version4.9.7 / 5.2.7 
Target VersionFixed in Version 
Summary0006354: oxarticles::getCustomerAlsoBoughtThisProducts missing return

in case there is no also bought product the function will nothing return
- there is no explicit 'return null'
- there is no explicit 'return array()'
- there is no explicit 'return false'

please add one of these option to point out how to handle this case of 'empty reply'

TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined



2016-03-21 21:12

reporter   ~0011502

@moment this will work without warning&error:

$aProducts = $oArticle->getCustomerAlsoBoughtThisProducts();
if (is_array($aProducts) && count($aProducts) > 0) {
    foreach ($aProducts AS $sKeyArt => $oAlsoArt) {
        //do bla

@moment this will throw a warning, if empty return (null):
foreach ($oArticle->getCustomerAlsoBoughtThisProducts() AS $sKeyArt => $oAlsoArt) {
    //do bla


2016-03-22 10:19

administrator   ~0011503

However, regardless of the return value, you have to check before using the variable in your foreach loop to NUll, otherwise a warning is thrown.


2016-03-22 10:20

reporter   ~0011504

Last edited: 2016-03-22 10:21

View 2 revisions

If there is no return null is returned: