OpenCart OCMOD and VQMOD Modification Systems

后端 未结 1 1255
攒了一身酷
攒了一身酷 2021-01-19 15:37

I am new to OpenCart OCMOD and VQMOD systems. So I need some help. My questions are.

  1. It is said that OCMOD is OC2+ default system. It is also said we have to

1条回答
  •  生来不讨喜
    2021-01-19 16:17

    First time we were talking about general OCMOD and VQMOD logic. This time I'll describe the OCMOD working experience (VQMOD works mostly the same and is outdated, so I will omit it). OCMOD itself is an engine (built in OpenCart since 2.X). We need to place in this engine an instructions to make it works. The instruction files are in XML format and has specific names, like my_file.ocmod.xml, where .ocmod.xml ending is required.

    Here is an example of OCMOD file

    
    
      My OCMOD file
      my-ocmod
      1.0
      Me
      http://mywebsite.com
    
      
        
          ]]>
          Add Something
    ]]> config->get('config_name');]]> config->get('config_name') . $this->document->getDescription(); ]]>

    Here we have 2 instructions (operations) in 2 different file (we can implement multiple operations in a single file as well). In operation we are searching for a line of the code in original core file and add before/after or replace it with tho code in add tag. Here is OCMOD file documentation, might help with .ocmod.xml file building.

    When you have .ocmod.xml file - you need to install it. There are two different ways to do it:

    1. Insert file in /system folder and clear cache.
    2. In admin panel in Extension - Installer install your .ocmod.xml file and clear cache. This case is better to manage. You can find your OCMOD files in Extension - Extension. These are not files, but a database entry. To edit them after installation you may need OCMOD editor.

    In some cases you could see .ocmod.zip archive with install.xml and upload folder. It could be the module with OCMOD file and additional files, compiled in a single installer.

    ABOUT CHANGES

    Now, when we have a file with operations .ocmod.xml installed and cache is cleared - system creates core files copies and keep them in /system/storage/modifications/.... If we take the code from the example - you will find file /system/storage/modifications/catalog/view/theme/default/template/common/header.twig with implemented changes from .ocmod.xml.

    So that's it. OCMOD works as simple as this. As soon as you have installed any .ocmod.xml file - this file is keeps in OpenCart, and implement operations after every cache cleaning. You made changes in .ocmod.xml file - clear the cache. Installed new .ocmod.xml - clear the cache. Removed some old .ocmod.xml - clear the cache.

    After upgrading OpenCart version - OCMOD files may stay untouched. But if they are gone - just install them again (you should save them before somewhere).

    P.S. Different .ocmod.xml files can affect on the same core file. This is absolutely OK.

0 讨论(0)
提交回复
热议问题