I'm working on an heavy customised magento version. Cancelling an order returned this fatal error:

Mage_Catalog_Model_Product_TYPE not found 

on this line code:

if($parent->getTypeId() == Mage_Catalog_Model_Product_TYPE::TYPE_CONFIGURABLE)

I fixed changing it to

if($parent->getTypeId() == 'configurable')

Can you please tell me what's the difference between them and if my solution can lead to other issues? many thanks

2 Answers 2


Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE (notice the capitalization, which was the source of your error) is a constant. Using a constant for values that won't change is preferred over writing "magic strings"1 all over the application.


  • no errors due to typos. If you misspell the string, chances are, you won't notice until much later. If you reference a non existent constant, the compiler complains immediately (or with PHP, your IDE or static code analysis tools like CodeSniffer)
  • easier to refactor
  • more context, thus easier to understand. It is clear, where the value comes from and what purpose it serves

1) Read this: https://stackoverflow.com/questions/47882/what-is-a-magic-number-and-why-is-it-bad - it is about magic numbers, but magic strings are almost as bad


It should be Mage_Catalog_Model_Product_Type and not Mage_Catalog_Model_Product_TYPE (note the capitalisation on the last word)

  • thanks, did't see the difference. but what about my solution?
    – apedic
    Commented Aug 21, 2015 at 13:48
  • Your solution would work but is much less elegant as you hard-code values. Commented Aug 21, 2015 at 13:50

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.