Plugin Directory

Changeset 1912165


Ignore:
Timestamp:
07/20/2018 11:45:16 AM (8 years ago)
Author:
alexwing
Message:

Fix reimport categories images

Location:
woo-oscommerce-sync/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • woo-oscommerce-sync/trunk/readme.txt

    r1912126 r1912165  
    55Requires at least: 3.5.1
    66Tested up to: 4.9.4–es_ES
    7 Stable tag: 2.0.4
     7Stable tag: 2.0.5
    88License: AGPLv3.0 or later
    99License URI: http://opensource.org/licenses/AGPL-3.0
     
    7070
    7171== Changelog ==
     72= 2.0.5 =
     73* Fix reimport categories images
     74
    7275= 2.0.4 =
    7376* Add field for custom images directory on osCommerce
  • woo-oscommerce-sync/trunk/woocommerce-osc-sync.php

    r1912130 r1912165  
    55  Description: Import products, categories, customers and orders from osCommerce to Woocommerce
    66  Author: Alejandro Aranda
    7   Version: 2.0.4
     7  Version: 2.0.5
    88  Author URI: http://www.aaranda.es
    99  Original Author: David Barnes
     
    111111                                if (!empty($_POST['images_url'])) {
    112112                                    //otw_log("importCategories", "Image: " . rtrim($_POST['store_url'], '/') . '/image/' . urlencode($category['categories_image']));
    113                                     $url = rtrim($_POST['store_url'], '/') . '/' . rtrim($_POST['store_url'], '/') . '/' . urlencode($category['categories_image']);
     113                                    $url = rtrim($_POST['store_url'], '/') . '/' . rtrim($_POST['images_url'], '/') . '/' . urlencode($category['categories_image']);
    114114                                } else {                                                                                   //otw_log("importCategories", "Image: " . rtrim($_POST['store_url'], '/') . '/image/' . urlencode($category['categories_image']));
    115115                                    $url = rtrim($_POST['store_url'], '/') . '/image/' . urlencode($category['categories_image']);
    116116                                }
    117 
     117                                otw_log("importCategories", "Image: " .$url);
    118118                                $attach_id = otw_import_image($url);
    119119                            }
     
    126126                        $import_cat_counter ++;
    127127                    } else {
    128                         otw_log("importCategories", "Edit Categorie: " . json_encode($category));
     128                        otw_log("importCategories", "Edit Categorie: ".$term['term_id'] .".-." . json_encode($category));
     129                       
     130                        delete_option('product_cat_children'); // clear the cache
     131
     132                        $attach_id = 0;
     133                        if ($category['categories_image'] != '') {
     134                            if (esc_url($_POST['store_url'])) {
     135
     136                                if (!empty($_POST['images_url'])) {
     137                                    //otw_log("importCategories", "Image: " . rtrim($_POST['store_url'], '/') . '/image/' . urlencode($category['categories_image']));
     138                                    $url = rtrim($_POST['store_url'], '/') . '/' . rtrim($_POST['images_url'], '/') . '/' . urlencode($category['categories_image']);
     139                                } else {                                                                                   //otw_log("importCategories", "Image: " . rtrim($_POST['store_url'], '/') . '/image/' . urlencode($category['categories_image']));
     140                                    $url = rtrim($_POST['store_url'], '/') . '/image/' . urlencode($category['categories_image']);
     141                                }
     142                                 otw_log("importCategories", "Image: " .$url);
     143                                $attach_id = otw_import_image($url);
     144                            }
     145                        }
     146                        delete_woocommerce_term_meta($term['term_id'], 'thumbnail_id');
     147                        add_woocommerce_term_meta($term['term_id'], 'thumbnail_id', (int) $attach_id);
    129148                        otw_run_cats($category['categories_id'], $term['term_id']);
    130149                    }
     
    520539
    521540                                        if (!empty($_POST['images_url'])) {
    522                                             $url = rtrim($_POST['store_url'], '/') . '/' . rtrim($_POST['store_url'], '/') . '/' . ($product['image']);
     541                                            $url = rtrim($_POST['store_url'], '/') . '/' . rtrim($_POST['images_url'], '/') . '/' . ($product['image']);
    523542                                        } else {                                                                                 
    524543                                            $url = rtrim($_POST['store_url'], '/') . '/images/' . ($product['image']);
     
    769788                    <p><label class="control-label">Limit (how many produts imported): <input type="text" name="limit" value="<?php echo sanitize_text_field($_POST['limit']); ?>"></label></p>
    770789                    <p>Enter your oscommerce database information (you will need remote access to your oscommerce database)</p>
    771                     <p><label class="control-label">osCommerce store URL: <input type="text" name="store_url" value="<?php echo sanitize_text_field($_POST['store_url']); ?>"></label><label class="control-label">&nbsp;&nbsp;&nbsp;Images directory: <small>(empty directory "/image") </small><input type="text" name="images_url" value="<?php echo sanitize_text_field($_POST['images_url']); ?>"></label></p>
     790                    <p><label class="control-label">osCommerce store URL: <input type="text" name="store_url" value="<?php echo sanitize_text_field($_POST['store_url']); ?>"></label><label class="control-label">&nbsp;&nbsp;&nbsp;Images directory: <small>(empty directory "image") </small><input type="text" name="images_url" value="<?php echo sanitize_text_field($_POST['images_url']); ?>"></label></p>
    772791                    <p><label class="control-label">osCommerce Database Host: <input type="text" name="store_host" value="localhost"></label></p>
    773792                    <p><label class="control-label">osCommerce Database User: <input type="text" name="store_user" value="<?php echo sanitize_text_field($_POST['store_user']); ?>"></label></p>
Note: See TracChangeset for help on using the changeset viewer.