1

make one module

using that module i add tab in order view now when i m click on button that time in url 404 accours

module name: orderattachments

controller name: orderattachments

Action name: save

my url:

 url: '<?php echo Mage::helper("adminhtml")->getUrl('orderattachments/adminhtml/orderattachments/save')?>'

what is wrong in my url

config.xml:

  <?xml version="1.0"?>
<config>
<modules>
    <File_OrderAttachments>
        <version>1.0.1</version>
    </File_OrderAttachments>
</modules>

<global>
<models>
        <orderattachments>
            <class>File_Orderattachments_Model</class>
            <resourceModel>orderattachments_mysql4</resourceModel>
        </orderattachments>
         <orderattachments_mysql4>
            <class>File_Orderattachments_Model_Mysql4</class>
             <entities>
                <orderattachments>
                    <table>order_attachments</table>
                </orderattachments>
            </entities>
        </orderattachments_mysql4>
    </models>
    <blocks>
        <orderattachments>
            <class>File_OrderAttachments_Block</class>
        </orderattachments>
    </blocks>
    <helpers>
        <orderattachments>
            <class>File_OrderAttachments_Helper</class>
        </orderattachments>
    </helpers>  
    <resources>
        <orderattachments_setup>
            <setup>
                <module>File_OrderAttachments</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </orderattachments_setup>
        <orderattachments_write>
            <connection>
                <use>core_write</use>
            </connection>
        </orderattachments_write>
        <orderattachments_read>
            <connection>
                <use>core_read</use>
            </connection>
        </orderattachments_read>
    </resources>
</global>      
<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <orderattachments before="Mage_Adminhtml">File_OrderAttachments_Adminhtml</orderattachments>
                </modules>
                <frontName>orderattachments</frontName>
            </args>
        </adminhtml>
    </routers>
</admin>
<adminhtml>
   <layout>
        <updates>
            <orderattachments>
                <file>orderattachments.xml</file>
            </orderattachments>
        </updates>
    </layout>
</adminhtml>

OrderattachmentsController.php

 <?php
 class File_OrderAttachments_Adminhtml_OrderattachmentsController extends    Mage_Adminhtml_Controller_Action
 {


public function saveAction()
{
    if (isset($_FILES['file']['name']) && (file_exists($_FILES['file']['tmp_name'])))
    {
        try {   
            $uploader = new Varien_File_Uploader('file');
            $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
            $uploader->setAllowRenameFiles(false);
            $uploader->setFilesDispersion(false);

            $path = Mage::getBaseDir('media');
            $uploader->save($path, $_FILES['file']['name'] );
            $data['file'] =$path.$_FILES['file']['name'];
            $fileName = $_FILES['file']['name'];
            echo $fileName;
        } 
        catch (Exception $e) {}     
    }

    $orderId = $_SESSION['id'];
    $con = Mage::getModel('orderattachments/orderattachments');
    $con->setData('order_id', $orderId);
     if (!empty($fileName)) 
    {       
        $con->setData('file', $fileName);   
    }
    $con->save();

}

}

  • Mage::helper('adminhtml')->getUrl('orderattachments/orderattachments/save'); – Amit Bera Jan 2 '15 at 10:55
  • not working again 404 error – ND17 Jan 2 '15 at 11:03
  • can you plase show config.xml file – Amit Bera Jan 2 '15 at 11:09
  • Mage::helper("adminhtml")->getUrl('adminhtml/orderattachments_orderattachments/save') – Amit Bera Jan 2 '15 at 11:15
  • Status Code:404 Not Found – ND17 Jan 2 '15 at 11:18
2

there lot of issue in you extension tag is not closed at config.xml. Also,There lot issue in you module.

config.xml code:

<?xml version="1.0"?>
<config>
  <modules>
    <File_OrderAttachments>
      <version>0.1.0</version>
    </File_OrderAttachments>
  </modules>
  <global>
    <helpers>
      <orderattachments>
        <class>File_OrderAttachments_Helper</class>
      </orderattachments>
    </helpers>
    <blocks>
      <orderattachments>
        <class>File_OrderAttachments_Block</class>
      </orderattachments>
    </blocks>
    <models>
      <orderattachments>
        <class>File_OrderAttachments_Model</class>
        <resourceModel>orderattachments_mysql4</resourceModel>
      </orderattachments>
      <orderattachments_mysql4>
        <class>File_OrderAttachments_Model_Mysql4</class>
        <entities>        
              <orderattachments>
                <table>order_attachments</table>
              </orderattachments>
        </entities>
      </orderattachments_mysql4>
    </models>
    <resources>
      <orderattachments_setup>
        <setup>
          <module>File_OrderAttachments</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </orderattachments_setup>
      <orderattachments_write>
        <connection>
          <use>core_write</use>
        </connection>
      </orderattachments_write>
      <orderattachments_read>
        <connection>
          <use>core_read</use>
        </connection>
      </orderattachments_read>
    </resources>
  </global>
  <admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <File_OrderAttachments before="Mage_Adminhtml">File_OrderAttachments_Adminhtml</File_OrderAttachments>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
  <adminhtml>
    <menu>
      <orderattachments module="orderattachments">
        <title>OrderAttachments</title>
        <sort_order>100</sort_order>
        <children>
          <orderattachments module="orderattachments">
            <title>Manage Orderattachments</title>
            <sort_order>0</sort_order>
            <action>adminhtml/orderattachments</action>
          </orderattachments>
        </children>
      </orderattachments>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <orderattachments translate="title" module="orderattachments">
              <title>OrderAttachments</title>
              <sort_order>1000</sort_order>
              <children>
          <orderattachmentsbackend translate="title">
            <title>Backend Page Title</title>
          </orderattachmentsbackend>
          <orderattachments translate="title">
            <title>Manage Orderattachments</title>
            <sort_order>0</sort_order>
          </orderattachments>
              </children>
            </orderattachments>
          </children>
        </admin>
      </resources>
    </acl>
    <layout>
      <updates>
        <orderattachments>
          <file>orderattachments.xml</file>
        </orderattachments>
      </updates>
    </layout>
  </adminhtml>
</config> 

You can get url by Mage::helper("adminhtml")->getUrl('adminhtml/orderattachments/save'); means

Mage::helper("adminhtml")->getUrl('adminhtml/controllername
/action');
  • in your config there is menu that is not needed in my project i have to add tab in order view – ND17 Jan 2 '15 at 13:43
  • Then just remove it from <menu> .... </menu> – Amit Bera Jan 2 '15 at 14:01

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.