0

Im trying to add a button to the order view page on the admin, next on the credit memo for example or something similiar, but is not showing the button, and i have no idea how to test it to find the problem.

Here is my code, maybe someone can notice any problem.

config.xml

<config>
    <modules>
        <Cloud_Magni>
            <version>0.1.0</version>
        </Cloud_Magni>
    </modules>
    <global>
        <models>
            <magni>
                <class>Cloud_Magni_Model</class>
            </magni>
        </models>


        <resources>

            <invoicedocs_setup>
                <setup>
                    <module>Cloud_Magni</module>
                    <class>Cloud_Magni_Model_Resource_Mysql4_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </invoicedocs_setup>


            <invoicedocs_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </invoicedocs_write>
            <invoicedocs_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </invoicedocs_read>
        </resources>

        <blocks>
            <magnifi>
                <class>Cloud_Magni_Block</class>
            </magnifi>

        <adminhtml>
            <rewrite>
                <sales_order_view>Cloud_Magni_Block_Adminhtml_Sales_Order_View</sales_order_view>
            </rewrite>
        </adminhtml>
        </blocks>

        <helpers>
            <magnifi>
                <class>Cloud_Magni_Helper</class>
            </magnifi>
        </helpers>
        <events>


            <sales_order_invoice_pay>
                <observers>
                    <magni>
                        <type>model</type>
                        <class>magni/observer</class>
                        <method>createInvoice</method>
                    </magni>
                </observers>
            </sales_order_invoice_pay>


            <sales_order_creditmemo_save_after>
                <observers>
                    <magni>
                        <type>model</type>
                        <class>magni/observer</class>
                        <method>createCredit</method>
                    </magni>
                </observers>
            </sales_order_creditmemo_save_after>
        </events>
    </global>
</config>

View.php:

class Cloud_Magni_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
    public function  __construct() {

        parent::__construct();

        $this->_addButton('magni', array(
            $message = "are you sure?",
            'label'     => Mage::helper('Sales')->__('Segunda Fatura'),
            'onclick'   => "confirmSetLocation('{$message}','{$this->getUrl('Cloud_Magni')}')"
        ));
    }
}
0

Now try this.

app/etc/modules/Cloud_Magni.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Cloud_Magni>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.0.9</version>
    </Cloud_Magni>
  </modules>
</config>

app/code/local/Cloud/Magni/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Cloud_Magni>
      <version>0.0.9</version>
    </Cloud_Magni>
  </modules>
  <global>
    <helpers>
      <magni>
        <class>Cloud_Magni_Helper</class>
      </magni>
    </helpers>
    <blocks>
      <magni>
        <class>Cloud_Magni_Block</class>
      </magni>
            <adminhtml>
                <rewrite>
                    <sales_order_view>Cloud_Magni_Block_Adminhtml_Sales_Order_View</sales_order_view>
                </rewrite>
            </adminhtml>
    </blocks>
  </global>
</config>

app/code/local/Cloud/Magni/Block/Adminhtml/Sales/Order/View.php

<?php
class Cloud_Magni_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
{
    public function __construct()
    {
        $this->_objectId    = 'order_id';
        $this->_controller  = 'sales_order';
        $this->_mode        = 'view';

        parent::__construct();

        $this->_addButton('magni', array(
            $message = "are you sure123?",
            'label'     => Mage::helper('Sales')->__('Segunda Fatura'),
            'onclick'   => "confirmSetLocation('{$message}','{$this->getUrl('Cloud_Magni')}')"
        ));

    }
}

app/code/local/Cloud/Magni/Helper/Data.php

<?php
class Cloud_Magni_Helper_Data extends Mage_Core_Helper_Abstract
{
}

Now my side working so please check screen short.

enter image description here

  • What is different about this solution, what was missing? – Info E Jan 4 '18 at 13:47
  • IS not working, i put exactlly how you did but doesnt work, could you send me all your files from the extension to compare what is missing? – Info E Jan 4 '18 at 18:35
  • now check updated code all files modules. – Ravindrasinh Zala Jan 5 '18 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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