I made a curl function so that I can make an api call. Now the function I created is in helper and I call it with Mage::helper('xyz')->curlGet($url). This works but I am not sure whether this is the proper way. I have seen functions created in models. Is there some kind of function convention in magento? Sorry for sounding silly, I am a beginner.

2 Answers 2


If you are trying to curl an external website then it belongs in a helper (what you did is correct).

On the other hand, if you are trying to access some data within Magento then a Model is the way to go.

Sometimes you may have an interesting situation where curl is pulling data from another site and that data is model-like. In this case I would suggest creating a model that calls your helper, this way the curl call is abstracted.

See example below:

class Namespace_Module_Model_Charity extends Mage_Core_Model_Abstract {
      public function getCurlData($url){
             if($url){  // make sure url is passed
                  $data = Mage::helper('xyz')->curlGet($url);
                  return $data;
              return false; // if the url wasn't passed we want to know about it

create an model File in your Exention's model directory

class Namespace_Module_Model_Charity
    extends Mage_Core_Model_Abstract {

public function ModelExample()
     echo "Foo Bar";
     return ;


Now you can call this model function by Mage::getModel('namespace/module')->ModelExample();

Follow these tutorial series by Alan Storm

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.