I want to display a Red or Green button to my customers of our shop stocks. We have 2 attributes where we have this information (it's not a store qty stock). It are 2 similar text attributes.

I have tried this code, but it gives me an error:

if ($_product->getvoorraaduden ()):
    if($_product == '' || $_product <= 'onbekend'):
        echo $this->__('onbekend of niets');
    elseif($_product == '0'):
        echo 'Niet op voorraad';
        echo 'voldoende voorraad';

I hope you can help me please.


1 Answer 1


I don't exactly understand what you want to do with your two attributes, but i'll give you an idea !

First, i edited your code and you forgot to close your endif; tag.

Second, check if you get well your attribute var_dump($_product->getVoorraaduden()); nb: there is no space before () and getVoorraaduden() instead of getvoorraaduden() if your attribute is called voorraa_duden so it comes $_product->getVoorraaDuden() did you understand the trick ? ;)

Finally, check this config of your attribute, admin->manage attributes->Used in Product Listing-> set it to Yes then reindex all.

Now you do something like this :

if ($_product->getVoorraaduden()) :
    if ($_product->getVoorraaduden() == 'Niet op voorraad'): //here we compare with the attribute value
        echo $this->__('Niet op voorraad');
    elseif($_product->getVoorraaduden() == 'voldoende voorraad'):
        echo $this->__('voldoende voorraad');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.