示例#1
0
 static function putProduct($info, $features = 0, $bAddParentCategories = false)
 {
     static $sep = '';
     if (!$sep) {
         $sep = (is_null(Tools::getValue('multiple_value_separator')) or trim(Tools::getValue('multiple_value_separator')) == '') ? ',' : Tools::getValue('multiple_value_separator');
     }
     if (!is_array($info)) {
         return false;
     }
     if (isset($info['category'])) {
         $r_cats =& $info['category'];
         if (is_array($r_cats)) {
             $r_cats = implode($sep, $r_cats);
         }
     }
     if (isset($info['tags'])) {
         $r_tags =& $info['tags'];
         if (is_array($r_tags)) {
             $r_tags = implode($sep, $r_tags);
         }
     }
     if (isset($info['image'])) {
         $r_imgs =& $info['image'];
         if (is_array($r_imgs)) {
             $r_imgs = implode($sep, $r_imgs);
         }
     }
     self::prepare(1);
     $import = new AdminImport();
     $id = $import->productImportRow($info, $features, $bAddParentCategories);
     return $id;
 }
示例#2
0
 public function __construct()
 {
     $this->entities = array_flip(array($this->l('Categories'), $this->l('Products'), $this->l('Combinations'), $this->l('Customers'), $this->l('Addresses'), $this->l('Manufacturers'), $this->l('Suppliers')));
     switch ((int) Tools::getValue('entity')) {
         case $this->entities[$this->l('Combinations')]:
             self::$required_fields = array('id_product', 'options');
             $this->available_fields = array('no' => array('label' => $this->l('Ignore this column')), 'id_product' => array('label' => $this->l('Product ID') . '*'), 'options' => array('label' => $this->l('Options (Group:Value)') . '*'), 'reference' => array('label' => $this->l('Reference')), 'supplier_reference' => array('label' => $this->l('Supplier reference')), 'ean13' => array('label' => $this->l('EAN13')), 'upc' => array('label' => $this->l('UPC')), 'wholesale_price' => array('label' => $this->l('Wholesale price')), 'price' => array('label' => $this->l('Price')), 'ecotax' => array('label' => $this->l('Ecotax')), 'quantity' => array('label' => $this->l('Quantity')), 'weight' => array('label' => $this->l('Weight')), 'default_on' => array('label' => $this->l('Default')), 'image_position' => array('label' => $this->l('Image position'), 'help' => $this->l('Position of the product image to use for this combination. If you use this field, leave image URL empty.')), 'image_url' => array('label' => $this->l('Image URL')));
             self::$default_values = array('reference' => '', 'supplier_reference' => '', 'ean13' => '', 'upc' => '', 'wholesale_price' => 0, 'price' => 0, 'ecotax' => 0, 'quantity' => 0, 'weight' => 0, 'default_on' => 0);
             break;
         case $this->entities[$this->l('Categories')]:
             $this->available_fields = array('no' => array('label' => $this->l('Ignore this column')), 'id' => array('label' => $this->l('ID')), 'active' => array('label' => $this->l('Active (0/1)')), 'name' => array('label' => $this->l('Name *')), 'parent' => array('label' => $this->l('Parent category')), 'description' => array('label' => $this->l('Description')), 'meta_title' => array('label' => $this->l('Meta-title')), 'meta_keywords' => array('label' => $this->l('Meta-keywords')), 'meta_description' => array('label' => $this->l('Meta-description')), 'link_rewrite' => array('label' => $this->l('URL rewritten')), 'image' => array('label' => $this->l('Image URL')));
             self::$default_values = array('active' => '1', 'parent' => '1', 'link_rewrite' => '');
             break;
         case $this->entities[$this->l('Products')]:
             self::$validators['image'] = array('AdminImport', 'split');
             $this->available_fields = array('no' => array('label' => $this->l('Ignore this column')), 'id' => array('label' => $this->l('ID')), 'active' => array('label' => $this->l('Active (0/1)')), 'name' => array('label' => $this->l('Name *')), 'category' => array('label' => $this->l('Categories (x,y,z...)')), 'price_tex' => array('label' => $this->l('Price tax excl.')), 'price_tin' => array('label' => $this->l('Price tax incl.')), 'id_tax_rules_group' => array('label' => $this->l('Tax rules id')), 'wholesale_price' => array('label' => $this->l('Wholesale price')), 'on_sale' => array('label' => $this->l('On sale (0/1)')), 'reduction_price' => array('label' => $this->l('Discount amount')), 'reduction_percent' => array('label' => $this->l('Discount percent')), 'reduction_from' => array('label' => $this->l('Discount from (yyyy-mm-dd)')), 'reduction_to' => array('label' => $this->l('Discount to (yyyy-mm-dd)')), 'reference' => array('label' => $this->l('Reference #')), 'supplier_reference' => array('label' => $this->l('Supplier reference #')), 'supplier' => array('label' => $this->l('Supplier')), 'manufacturer' => array('label' => $this->l('Manufacturer')), 'ean13' => array('label' => $this->l('EAN13')), 'upc' => array('label' => $this->l('UPC')), 'ecotax' => array('label' => $this->l('Ecotax')), 'weight' => array('label' => $this->l('Weight')), 'quantity' => array('label' => $this->l('Quantity')), 'description_short' => array('label' => $this->l('Short description')), 'description' => array('label' => $this->l('Description')), 'tags' => array('label' => $this->l('Tags (x,y,z...)')), 'meta_title' => array('label' => $this->l('Meta-title')), 'meta_keywords' => array('label' => $this->l('Meta-keywords')), 'meta_description' => array('label' => $this->l('Meta-description')), 'link_rewrite' => array('label' => $this->l('URL rewritten')), 'available_now' => array('label' => $this->l('Text when in-stock')), 'available_later' => array('label' => $this->l('Text if back-order allowed')), 'available_for_order' => array('label' => $this->l('Available for order')), 'date_add' => array('label' => $this->l('Date add product')), 'show_price' => array('label' => $this->l('Show price')), 'image' => array('label' => $this->l('Image URLs (x,y,z...)')), 'delete_existing_images' => array('label' => $this->l('Delete existing images (0 = no, 1 = yes)'), 'help' => $this->l('If you do not specify this column and you specify the column images, all images of the product will be replaced by those specified in the import file')), 'feature' => array('label' => $this->l('Feature')), 'online_only' => array('label' => $this->l('Only available online')), 'condition' => array('label' => $this->l('Condition')));
             self::$default_values = array('id_category' => array(1), 'id_category_default' => 1, 'active' => '1', 'quantity' => 0, 'price' => 0, 'id_tax_rules_group' => 0, 'description_short' => array((int) Configuration::get('PS_LANG_DEFAULT') => ''), 'link_rewrite' => array((int) Configuration::get('PS_LANG_DEFAULT') => ''), 'online_only' => 0, 'date_add' => date('Y-m-d H:i:s'), 'condition' => 'new');
             break;
         case $this->entities[$this->l('Customers')]:
             //Overwrite required_fields AS only email is required whereas other entities
             self::$required_fields = array('email', 'passwd', 'lastname', 'firstname');
             $this->available_fields = array('no' => array('label' => $this->l('Ignore this column')), 'id' => array('label' => $this->l('ID')), 'active' => array('label' => $this->l('Active  (0/1)')), 'id_gender' => array('label' => $this->l('Gender ID (Mr = 1, Ms = 2, else 9)')), 'email' => array('label' => $this->l('E-mail *')), 'passwd' => array('label' => $this->l('Password *')), 'birthday' => array('label' => $this->l('Birthday (yyyy-mm-dd)')), 'lastname' => array('label' => $this->l('Lastname *')), 'firstname' => array('label' => $this->l('Firstname *')), 'newsletter' => array('label' => $this->l('Newsletter (0/1)')), 'optin' => array('label' => $this->l('Opt in (0/1)')));
             self::$default_values = array('active' => '1');
             break;
         case $this->entities[$this->l('Addresses')]:
             //Overwrite required_fields
             self::$required_fields = array('lastname', 'firstname', 'address1', 'postcode', 'country', 'city');
             $this->available_fields = array('no' => array('label' => $this->l('Ignore this column')), 'id' => array('label' => $this->l('ID')), 'alias' => array('label' => $this->l('Alias *')), 'active' => array('label' => $this->l('Active  (0/1)')), 'customer_email' => array('label' => $this->l('Customer e-mail')), 'manufacturer' => array('label' => $this->l('Manufacturer')), 'supplier' => array('label' => $this->l('Supplier')), 'company' => array('label' => $this->l('Company')), 'lastname' => array('label' => $this->l('Lastname *')), 'firstname' => array('label' => $this->l('Firstname *')), 'address1' => array('label' => $this->l('Address 1 *')), 'address2' => array('label' => $this->l('Address 2')), 'postcode' => array('label' => $this->l('Postcode*/ Zipcode*')), 'city' => array('label' => $this->l('City *')), 'country' => array('label' => $this->l('Country *')), 'state' => array('label' => $this->l('State')), 'other' => array('label' => $this->l('Other')), 'phone' => array('label' => $this->l('Phone')), 'phone_mobile' => array('label' => $this->l('Mobile Phone')), 'vat_number' => array('label' => $this->l('VAT number')));
             self::$default_values = array('alias' => 'Alias', 'postcode' => 'X');
             break;
         case $this->entities[$this->l('Manufacturers')]:
         case $this->entities[$this->l('Suppliers')]:
             //Overwrite validators AS name is not MultiLangField
             self::$validators = array('description' => array('AdminImport', 'createMultiLangField'), 'short_description' => array('AdminImport', 'createMultiLangField'), 'meta_title' => array('AdminImport', 'createMultiLangField'), 'meta_keywords' => array('AdminImport', 'createMultiLangField'), 'meta_description' => array('AdminImport', 'createMultiLangField'));
             $this->available_fields = array('no' => array('label' => $this->l('Ignore this column')), 'id' => array('label' => $this->l('ID')), 'active' => array('label' => $this->l('Active (0/1)')), 'name' => array('label' => $this->l('Name *')), 'description' => array('label' => $this->l('Description')), 'short_description' => array('label' => $this->l('Short description')), 'meta_title' => array('label' => $this->l('Meta-title')), 'meta_keywords' => array('label' => $this->l('Meta-keywords')), 'meta_description' => array('label' => $this->l('Meta-description')));
             break;
     }
     parent::__construct();
 }
示例#3
0
 public function __construct()
 {
     $this->entities = array_flip(array($this->l('Categories'), $this->l('Products'), $this->l('Attributes'), $this->l('Customers'), $this->l('Addresses'), $this->l('Manufacturers'), $this->l('Suppliers')));
     switch (intval(Tools::getValue('entity'))) {
         case $this->entities[$this->l('Attributes')]:
             self::$required_fields = array('id_product', 'options');
             $this->available_fields = array('no' => $this->l('Ignore this column'), 'id_product' => $this->l('Product ID'), 'options' => $this->l('Options'), 'reference' => $this->l('Reference'), 'supplier_reference' => $this->l('Supplier reference'), 'ean13' => $this->l('EAN13'), 'wholesale_price' => $this->l('Wholesale price'), 'price' => $this->l('Price'), 'ecotax' => $this->l('Ecotax'), 'quantity' => $this->l('Quantity'), 'weight' => $this->l('Weight'), 'default_on' => $this->l('Default'));
             self::$default_values = array('reference' => '', 'supplier_reference' => '', 'ean13' => '', 'wholesale_price' => 0, 'price' => 0, 'ecotax' => 0, 'quantity' => 0, 'weight' => 0, 'default_on' => 0);
             break;
         case $this->entities[$this->l('Categories')]:
             $this->available_fields = array('no' => $this->l('Ignore this column'), 'id' => $this->l('ID'), 'active' => $this->l('Active (0/1)'), 'name' => $this->l('Name *'), 'parent' => $this->l('Parent category'), 'description' => $this->l('Description'), 'meta_title' => $this->l('Meta-title'), 'meta_keywords' => $this->l('Meta-keywords'), 'meta_description' => $this->l('Meta-description'), 'link_rewrite' => $this->l('URL rewrited'), 'image' => $this->l('Image URL'));
             self::$default_values = array('active' => '1', 'parent' => '1', 'link_rewrite' => '');
             break;
         case $this->entities[$this->l('Products')]:
             self::$validators['image'] = array('AdminImport', 'split');
             $this->available_fields = array('no' => $this->l('Ignore this column'), 'id' => $this->l('ID'), 'active' => $this->l('Active (0/1)'), 'name' => $this->l('Name *'), 'category' => $this->l('Categories (x,y,z...)'), 'price_tex' => $this->l('Price tax excl.'), 'price_tin' => $this->l('Price tax incl.'), 'tax_rate' => $this->l('Tax rate'), 'wholesale_price' => $this->l('Wholesale price'), 'on_sale' => $this->l('On sale (0/1)'), 'reduction_price' => $this->l('Reduction amount'), 'reduction_percent' => $this->l('Reduction per cent'), 'reduction_from' => $this->l('Reduction from (yyyy-mm-dd)'), 'reduction_to' => $this->l('Reduction to (yyyy-mm-dd)'), 'reference' => $this->l('Reference #'), 'supplier_reference' => $this->l('Supplier reference #'), 'supplier' => $this->l('Supplier'), 'manufacturer' => $this->l('Manufacturer'), 'ean13' => $this->l('EAN13'), 'ecotax' => $this->l('Ecotax'), 'weight' => $this->l('Weight'), 'quantity' => $this->l('Quantity'), 'description_short' => $this->l('Short description'), 'description' => $this->l('Description'), 'tags' => $this->l('Tags (x,y,z...)'), 'meta_title' => $this->l('Meta-title'), 'meta_keywords' => $this->l('Meta-keywords'), 'meta_description' => $this->l('Meta-description'), 'available_now' => $this->l('Text when in-stock'), 'available_later' => $this->l('Text if back-order allowed'), 'image' => $this->l('Image URLs (x,y,z...)'), 'feature' => $this->l('Feature'));
             self::$default_values = array('id_category' => array(1), 'id_category_default' => 1, 'active' => '1', 'quantity' => 0, 'price' => 0, 'id_tax' => 0, 'description_short' => array(intval(Configuration::get('PS_LANG_DEFAULT')) => ''), 'link_rewrite' => array(intval(Configuration::get('PS_LANG_DEFAULT')) => ''));
             break;
         case $this->entities[$this->l('Customers')]:
             //Overwrite required_fields AS only email is required whereas other entities
             self::$required_fields = array('email', 'passwd', 'lastname', 'firstname');
             $this->available_fields = array('no' => $this->l('Ignore this column'), 'id' => $this->l('ID'), 'active' => $this->l('Active  (0/1)'), 'id_gender' => $this->l('Gender ID (Mr = 1, Ms = 2, else 9)'), 'email' => $this->l('E-mail *'), 'passwd' => $this->l('Password *'), 'birthday' => $this->l('Birthday (yyyy-mm-dd)'), 'lastname' => $this->l('Lastname *'), 'firstname' => $this->l('Firstname *'), 'newsletter' => $this->l('Newsletter (0/1)'), 'optin' => $this->l('Optin (0/1)'));
             self::$default_values = array('active' => '1');
             break;
         case $this->entities[$this->l('Addresses')]:
             //Overwrite required_fields
             self::$required_fields = array('lastname', 'firstname', 'address1', 'postcode', 'country', 'city');
             $this->available_fields = array('no' => $this->l('Ignore this column'), 'id' => $this->l('ID'), 'alias' => $this->l('Alias *'), 'active' => $this->l('Active  (0/1)'), 'customer_email' => $this->l('Customer e-mail'), 'manufacturer' => $this->l('Manufacturer'), 'supplier' => $this->l('Supplier'), 'company' => $this->l('Company'), 'lastname' => $this->l('Lastname *'), 'firstname' => $this->l('Firstname *'), 'address1' => $this->l('Address 1 *'), 'address2' => $this->l('Address 2'), 'postcode' => $this->l('Postcode *'), 'city' => $this->l('City *'), 'country' => $this->l('Country *'), 'state' => $this->l('State'), 'other' => $this->l('Other'), 'phone' => $this->l('Phone'), 'phone_mobile' => $this->l('Mobile Phone'));
             self::$default_values = array('alias' => 'Alias', 'postcode' => 'X', trunk / img / tmp / product_mini_9 . jpg);
             break;
         case $this->entities[$this->l('Manufacturers')]:
         case $this->entities[$this->l('Suppliers')]:
             //Overwrite validators AS name is not MultiLangField but only description is needed AS MultiLangField
             self::$validators = array('description' => array('AdminImport', 'createMultiLangField'));
             $this->available_fields = array('no' => $this->l('Ignore this column'), 'id' => $this->l('ID'), 'name' => $this->l('Name *'), 'description' => $this->l('Description'));
             break;
     }
     parent::__construct();
 }
示例#4
0
    $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
    $product = new Product((int) Tools::getValue('id_product'));
    if (!Validate::isLoadedObject($product)) {
        die(Tools::displayError('Product cannot be loaded'));
    }
    $switchArray = array(3 => 'displayFormPrices', 4 => 'displayFormAttributes', 5 => 'displayFormFeatures', 6 => 'displayFormCustomization', 7 => 'displayFormAttachments');
    $currentIndex = 'index.php?tab=AdminCatalog';
    if (key_exists($step, $switchArray)) {
        $admin->{$switchArray[$step]}($product, $languages, $defaultLanguage);
    }
}
if (isset($_GET['getAvailableFields']) and isset($_GET['entity'])) {
    $currentIndex = 'index.php?tab=AdminImport';
    $jsonArray = array();
    require_once dirname(__FILE__) . '/tabs/AdminImport.php';
    $import = new AdminImport();
    $languages = Language::getLanguages(false);
    $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
    $fields = $import->getAvailableFields(true);
    foreach ($fields as $field) {
        $jsonArray[] = '{"field":"' . addslashes($field) . '"}';
    }
    die('[' . implode(',', $jsonArray) . ']');
}
if (array_key_exists('ajaxModulesPositions', $_POST)) {
    $id_module = (int) Tools::getValue('id_module');
    $id_hook = (int) Tools::getValue('id_hook');
    $way = (int) Tools::getValue('way');
    $positions = Tools::getValue(strval($id_hook));
    $position = is_array($positions) ? array_search($id_hook . '_' . $id_module, $positions) : null;
    $module = Module::getInstanceById($id_module);
<?php

define('PS_ADMIN_DIR', getcwd());
include PS_ADMIN_DIR . '/../config/config.inc.php';
include PS_ADMIN_DIR . '/functions.php';
include_once './tabs/AdminImport.php';
if (!isset($_GET['entity'])) {
    die;
}
$import = new AdminImport();
switch ($_GET['entity']) {
    case 0:
        loadCategoriesPost();
        $import->categoryImport();
        break;
    case 1:
        loadProductsPost();
        $import->productImport();
        break;
    default:
        die;
        break;
}
function loadCategoriesPost()
{
    $_POST = array('tab' => 'AdminImport', 'skip' => '0', 'csv' => 'cat.csv', 'convert' => '', 'entity' => '0', 'separator' => ';', 'multiple_value_separator' => ',', 'import' => 'Importar datos CSV', 'type_value' => array(0 => 'id', 1 => 'active', 2 => 'name', 3 => 'parent', 4 => 'description', 5 => 'meta_title', 6 => 'meta_keywords', 7 => 'meta_description', 8 => 'link_rewrite', 9 => 'image'));
}
function loadProductsPost()
{
    $_POST = array('tab' => 'AdminImport', 'skip' => '0', 'csv' => 'pro.csv', 'convert' => '', 'entity' => '1', 'separator' => ';', 'multiple_value_separator' => ',', 'import' => 'Importar datos CSV', 'type_value' => array(0 => 'id', 1 => 'active', 2 => 'name', 3 => 'category', 4 => 'price_tex', 5 => 'tax_rate', 6 => 'wholesale_price', 7 => 'on_sale', 8 => 'reduction_price', 9 => 'reduction_percent', 10 => 'reduction_from', 11 => 'reduction_to', 12 => 'reference', 13 => 'supplier_reference', 14 => 'supplier', 15 => 'manufacturer', 16 => 'ean13', 17 => 'ecotax', 18 => 'weight', 19 => 'quantity', 20 => 'description_short', 21 => 'description', 22 => 'tags', 23 => 'meta_title', 24 => 'meta_keywords', 25 => 'meta_description', 26 => 'available_now', 27 => 'available_later', 28 => 'image', 29 => 'no'));
}