创建opencart 2.3模块

Create opencart 2.3 module

我正在为原来的 3.3 写一个扩展。由于文件只会更改,因此该模块仅包含一个 filename.ocmod.xml 文件。但是在安装扩展的时候,没有改变文件,也没有出现安装错误。我做错了什么? 这是我的 XML 文件 https://drive.google.com/file/d/1lR2_aRPtZ5Eve54jG6D-Rr0WlSxiIvdT/view?usp=sharing

不应该使用多行搜索操作...我刚刚修改了你的文件 安装后试试这个不要忘记在修改中刷新它

<?xml version="1.0" encoding="utf-8"?>
<modification>
<code>order_map</code>
<name>Order map</name>
<version>1.0</version>
<author>Kolesnikov Roman</author>
<link>https://opencart2x.ru</link>
<file path="admin/view/template/sale/order_list.tpl">
    <operation>
        <search><![CDATA[
           <?php echo $footer; ?>
        ]]></search>
        <add position="before"><![CDATA[
          <!-- markup disable price -->
            <script src="https://api-maps.yandex.ru/2.1/?lang=ru-RU" type="text/javascript"></script>
            <script type="text/javascript">
                var myMap;
                ymaps.ready(init); // Ожидание загрузки API с сервера Яндекса
                function init () {
                    var myMap = new ymaps.Map('map', {
                            center: [53.919166, 27.592527],
                            zoom: 10
                        }, {
                            searchControlProvider: 'yandex#search'
                        }
                    ),
                        objectManager = new ymaps.ObjectManager({
                            clusterize: true,
                            gridSize: 32
                        });
                    objectManager.objects.options.set('preset', 'islands#greenDotIcon');
                    objectManager.clusters.options.set('preset', 'islands#greenClusterIcons');
                    myMap.geoObjects.add(objectManager);
                    objectManager.add(<?php echo $addresses ?>);
                }
            </script>
            <div id="map" style="width: 100%; height: 500px"></div>
          <!-- end markup disable price -->
        ]]></add>
    </operation>
</file>

<file path="admin/controller/sale/order.php">
    <operation>
        <search><![CDATA[
                $results = $this->model_sale_order->getOrders($filter_data);
        ]]></search>
        <add position="after"><![CDATA[
            $addresses = "";

            function curl_get_contents($url){
                $curl = curl_init($url);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
                $data = curl_exec($curl);
                curl_close($curl);
                return $data;
            }

            $features = '';
            foreach($results as $result){
                if(!empty($result['shipping_address_1'])){
                    $url = 'https://geocode-maps.yandex.ru/1.x/?format=json&geocode='.$result['shipping_address_1'];
                    $response = json_decode(curl_get_contents($url), true);
                    $point = $response['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos'];
                    $point = explode(' ', $point);
                    $point = implode(', ', array_reverse($point));
                    $features .= '{
                        "type": "Feature",
                        "id": '.$result['order_id'].',
                        "geometry": {"type": "Point", "coordinates": ['.$point.']},
                        "properties": {"balloonContent": "'. $result['shipping_address_1'] .'", "clusterCaption": "", "hintContent": "", "iconCaption": "'. $result['order_id'] .'"}
                    },';
                }
                $addresses = '{
                    "type": "FeatureCollection",
                    "features": ['.$features.']
                }';
            }
        ]]></add>
    </operation>
</file>

<file path="admin/controller/sale/order.php">
    <operation>
        <search><![CDATA[
            'shipping_code' => $result['shipping_code'],
        ]]></search>
        <add><![CDATA[
            'shipping_address' => $result['shipping_address_1'],
        ]]></add>
    </operation>
</file>

<file path="admin/controller/sale/order.php">
    <operation>
        <search><![CDATA[
            $data['button_ip_add'] = $this->language->get('button_ip_add');
        ]]></search>
        <add><![CDATA[
            $data['addresses'] = $addresses ? $addresses : "{}";
        ]]></add>
    </operation>
</file>

<file path="admin/model/sale/order.php">
    <operation>
        <search><![CDATA[
            $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
        ]]></search>
        <add><![CDATA[
            $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.shipping_address_1, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
        ]]></add>
    </operation>
</file>

希望这个回答对您有所帮助