cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9 - What is the best way to edit core files?

Magento 1.9 - What is the best way to edit core files?

I need to edit -> app/design/adminhtml/default/default/template/sales/order/view/items.phtml, editing core files is dangerous, may i know how can i edit without affect core files.

 

eg: Some case we can edit the file app\design\frontend\default\theme327k\template instead of edit core path app\design\frontend\base\default\template. Same how to follow in app/design/adminhtml?

1 REPLY 1

Re: Magento 1.9 - What is the best way to edit core files?

Editing core files directly is not recommended as it can cause issues with compatibility and stability. Instead, you can create a custom module or theme that overrides the core file you want to modify. This way, your modifications will not be lost when you update the core files.

Here's how you can override the file "app/design/adminhtml/default/default/template/sales/order/view/items.phtml":

  1. Create a new module: You can create a new module using the following steps:

    • Create a new folder with the name of your module under "app/code/"

    • Create a new file "registration.php" in the module folder and add the following code:

      <?php
      \Magento\Framework\Component\ComponentRegistrar::register(
          \Magento\Framework\Component\ComponentRegistrar::MODULE,
          '[Vendor]_[Module]',
          __DIR__
      );
      Create a new file "module.xml" in the module folder and add the following code:
      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
          <module name="[Vendor]_[Module]" setup_version="1.0.0"/>
      </config>

      Create a new theme: If you don't want to create a new module, you can create a new theme instead. Here's how:

      • Create a new folder with the name of your theme under "app/design/adminhtml/"

      • Create a new file "theme.xml" in the theme folder and add the following code:

        <?xml version="1.0"?>
        <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
            <title>[Theme Title]</title>
            <parent>Magento/backend</parent>
        </theme>
        1. Copy the file you want to modify: Copy the file "app/design/adminhtml/default/default/template/sales/order/view/items.phtml" to your module or theme folder.

        2. Modify the file: Make your modifications to the copied file in your module or theme folder.

        3. Register your module or theme: Register your module or theme in Magento by running the following command in your Magento root directory:

          bin/magento setup:upgrade

          After completing these steps, your modifications to "app/design/adminhtml/default/default/template/sales/order/view/items.phtml" will be applied from your custom module or theme, rather than from the core files. This way, your modifications will not be lost when you update the core files.