Search code examples
phpmagentomagento-1.9payment-method

failed to open stream: No such file or directory on Magento Custom Payment Method


I've created an extension for ourselves which imports orders from an API. This happends via a cronjob. The import is working fine but now I have created a custom Payment Method.

Now when I want to set the custom method on the order it throws an error:

Failed opening 'Mage/Importer/Model/Method/Dobeno.php'

It doesn't recognize my model, which I do have registered in config.xml. In config.xml I have the following:

<global>
    <models>
        <dobeno>
            <class>Dobeno_Importer_Model</class>
        </dobeno>
    </models>
</global>
<default>
    <payment>
        <dobeno>
            <model>importer/method_dobeno</model>
            <active>1</active>
            <order_status>externalorder</order_status>
            <title>Dobeno external</title>
            <allowspecific>0</allowspecific>
            <shippingallowspecific>0</shippingallowspecific>
            <disallowspecificshippingmethods>0</disallowspecificshippingmethods>
            <display_zero_fee>0</display_zero_fee>
            <sort_order>1</sort_order>
        </dobeno>
    </payment>
</default>

And the cronjob works perfectly when I use a default payment method.

The code that sets the payment method: $quotePayment->setMethod('dobeno');

The file Dobeno/Importer/Model/Method/Dobeno.php:

class Dobeno_Importer_Model_Method_Dobeno extends Mage_Payment_Model_Method_Abstract
{
    protected $_code = 'dobeno';
    protected $_isInitializeNeeded      = true;
    protected $_canUseInternal          = false;
    protected $_canUseForMultishipping  = false;
}

Magento ver. 1.9.2.3


Solution

  • Finally found the problem. Was problem with the naming.

    Changed the XML to

    <global>
        <models>
            <dobeno_importer>
                <class>Dobeno_Importer_Model</class>
            </dobeno_importer>
        </models>
    </global>
    <default>
        <payment>
            <dobeno>
                <model>dobeno_importer/method_dobeno</model>
                <active>1</active>
                <order_status>externalorder</order_status>
                <title>Dobeno external</title>
                <allowspecific>0</allowspecific>
                <shippingallowspecific>0</shippingallowspecific>
                <disallowspecificshippingmethods>0</disallowspecificshippingmethods>
                <display_zero_fee>0</display_zero_fee>
                <sort_order>1</sort_order>
            </dobeno>
        </payment>
    </default>