Search code examples
opencartopencart-moduleopencart2.3

Create opencart 2.3 module


I am writing an Extension for the original 3.3. Since the files will only change, the module consists of only a filename.ocmod.xml file. But when installing the extension, no files are changed, but no installation errors occur. What have I done wrong? It's my XML file https://drive.google.com/file/d/1lR2_aRPtZ5Eve54jG6D-Rr0WlSxiIvdT/view?usp=sharing


Solution

  • Should not use multiple lines of search operation... I just modified your file try this after installation do not forget to refresh it in the modification

    <?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>
    

    Hope this answer might helpful to you