d_opencart_patch.md (5812B)
1 # OpenCart Patch API 2 Fix issues on Opencart 2.2.0.0 and below and add support for new Extension folder system. 3 4 ### Why? 5 To reduce the compatibility issues between OpenCart version, this extension provides the missing features and methods, that are available in 2.3.0.x. They are strictly set and will not change in the future, so that you can rely on them when developing. When a new version is added, they can be extended and modified to support the new changes, but will always have the same API. 6 7 8 # Docs 9 10 ## admin/model/extension/d_opencart_patch 11 12 ### /event 13 Basic event methods, that are missing in 2.2.0.0 and bellow. This Model will not implement support for Events on older version. For this please install **d_event_manager** 14 ```php 15 $this->load->model('extension/d_opencart_patch/event'); 16 $event_id = $this->model_extension_d_opencart_patch_event->addEvent($code, $trigger, $action); 17 ``` 18 19 20 **- addEvent($code, $trigger, $action, $status = 1)** 21 22 _default opencart method that sets an event. If it is called in an old OpenCart version, which has no support for new event structure, the installDatabase() will be called and the event table will be added_ 23 24 25 **- deleteEvent($code)** 26 27 _will delete all events with the same code name. this method is basic and is not good for removing a specific event. If you want more controll - use Event Manager_ 28 29 30 **- installDatabase()** 31 32 _adds event table to OpenCart and also checks for missing columns and adds them too_ 33 34 ### /extension 35 OpenCart default methods for managing extension in admin 36 ```php 37 $this->load->model('extension/d_opencart_patch/extension'); 38 $extensions = $this->model_extension_d_opencart_patch_extension->getInstalled("module"); 39 ``` 40 41 42 **- getInstalled($type)** 43 44 _default OpenCart method for returning all installed extensions by type_ 45 46 47 **- isInstalled($code, $type = false)** 48 49 _checks if the provided extension is installed by the codename. If you want a more strict check, supply the $type of the extension_ 50 51 52 **- install($type, $code)** 53 54 _default opencart method for installing extensions_ 55 56 57 **- uninstall($type, $code)** 58 59 _default opencart method for uninstalling extensions_ 60 61 ### /modification 62 OpenCarts OCmod system. Provides default modification methods as well as setModification. 63 ```php 64 $this->load->model('extension/d_opencart_patch/modification'); 65 $extensions = $this->model_extension_d_opencart_patch_modification->setModification("d_opencart_patch.xml", 1); 66 ``` 67 68 69 **- setModification($xml, $status = 1)** 70 71 _install a OCmod xml file on the fly. Provide a full path to the xml file beginign from root. Or you can provide the short path if your xml file is located in system/library/d_shopunity/install/_ 72 73 74 **- refreshCache()** 75 76 _refresh the OCmod cache. This will not trigger a maintenecne mode since this could result into crashing the store or removing it from the Google index without the administrator even noticing it_ 77 78 79 **- getModificationByCode($code)** 80 81 _returns the modification by Code. Code as we know it is avaliable starting from 2.0.1.x. In 2.0.0.0 code was XML. We suggest using getModificationByName() and specifiying the codename. And in the ocmod.xml keep the code and name identical_ 82 83 84 **- getModificationByName($code)** 85 86 _returns the modification by Name. Beucase Name was in OpenCart since 2.x it is better to use this option and keep the code and name identical_ 87 88 89 **- addModification($data)** 90 91 _default method for adding a OCmod modification to the database. Resolves conflict with 2.0.0.0 where code is actually xml. Use the latest $data structure. $data = array( 'code' , 'name', 'author', 'version', 'link', 'xml', 'status');_ 92 93 ### /setting 94 OpenCarts default settings methods fixed. These are one of the most often used methods and if they are changed, this will cause a great deal of updating. To avoid this, we added them here in case they ever do change. 95 ```php 96 $this->load->model('extension/d_opencart_patch/setting'); 97 $extensions = $this->model_extension_d_opencart_patch_setting->getSetting("d_opencart_patch.xml"); 98 ``` 99 100 101 **- getSetting($code, $store_id = 0)** 102 103 _same as default method_ 104 105 106 **- editSetting($code, $data, $store_id = 0)** 107 108 _same as default method_ 109 110 111 **- deleteSetting($code, $store_id = 0)** 112 113 _same as default method_ 114 115 116 **- editSettingValue($code = '', $key = '', $value = '', $store_id = 0)** 117 118 _same as default method_ 119 120 ### /store 121 Missing store methods 122 ```php 123 $this->load->model('extension/d_opencart_patch/store'); 124 $extensions = $this->model_extension_d_opencart_patch_store->getAllStores(); 125 ``` 126 127 128 **- getAllStores()** 129 130 _returns a list of all stores, even the 0 store, which is not in the database. this method is used mostly for a multistore to optimize your template code_ 131 132 ### /user 133 Conflict fix for older versions of OpenCart when library/user did not have user_group_id 134 ```php 135 $this->load->model('extension/d_opencart_patch/user'); 136 $extensions = $this->model_extension_d_opencart_patch_user->getGroupId(); 137 ``` 138 139 140 **- getGroupId()** 141 142 _returns getGroupId. Missing in opencart 2.0.0.0_ 143 144 ### /vqmod 145 Some handy methods for activating xml files. ALthough VQmod is oldschool it still to have for development. 146 147 ```php 148 $this->load->model('extension/d_opencart_patch/vqmod'); 149 $extensions = $this->model_extension_d_opencart_patch_vqmod->setModification('d_opencart_patch.xml'); 150 ``` 151 152 153 **- setModification()** 154 155 _manage your vqmod.xml files. Activating or deactivating is really just commenting out your vqmod.xml file._ 156 157 158 **- refreshCache()** 159 160 _refresh VQmod cache. Actually what is does is deletes the mods.cache file which vqmod uses to keep trek of chache updates. With the next call to server a new cache will be regenerated by vqmod_ 161 162 163 ## catalog/model/extension/d_opencart_patch 164 165 ### /design 166 This model will port the latest design methods to all previouse OpenCart versions. 167 168 ### /user 169