Jump to content

Custom/Adding new fields in import (Only Product entity) .csv


johnjasonz

Recommended Posts

  • 2 months later...

Hello,

 

Open prestashop/controllers/adminAdminImportController.php

 

entities "Products"


   	 case $this->entities[$this->l('Products')]:
			self::$validators['image'] = array(
				'AdminImportController',
				'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 when backorder allowed')),
				'available_for_order' => array('label' => $this->l('Available for order (0 = No, 1 = Yes)')),
				'condition' => array('label' => $this->l('Condition (new, used, refurbished)')),
				'cache_is_pack' => array('label' => $this->l('Pack (0 = Oui, 1 = Non)')),
				'is_virtual' => array('label' => $this->l('Is_virtual')),
				'visibility' => array('label' => $this->l('Visibilité (both, catalog, search, none)')),
				'width' => array('label' => $this->l('Width')),
				'height' => array('label' => $this->l('Height')),
				'depth' => array('label' => $this->l('Profondeur')),
				'date_add' => array('label' => $this->l('Product creation date')),
				'show_price' => array('label' => $this->l('Show price (0 = No, 1 = Yes)')),
				'image' => array('label' => $this->l('Image URLs (x,y,z...)')),
				'delete_existing_images' => array(
					'label' => $this->l('Delete existing images (0 = No, 1 = Yes)')
				),
				'features' => array('label' => $this->l('Feature(Name:Value:Position)')),
				'online_only' => array('label' => $this->l('Available online only (0 = No, 1 = Yes)')),
				'id_product_pack' => array('label' => $this->l('Id_product_pack')),
				'id_product_item' => array('label' => $this->l('Id_product_item')),
				'quantity' => array('label' => $this->l('Quantity')),
				'shop' => array(
					'label' => $this->l('ID / Name of shop'),
					'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, default shop will be used'),
				)
			);

Link to comment
Share on other sites

           	 } // Else If id product && id product already in base, trying to update
               else if ($product->id && Product::existsInDatabase((int)$product->id, 'product'))
               {
                   $datas = Db::getInstance()->getRow('
                       SELECT product_shop.`date_add`
                       FROM `'._DB_PREFIX_.'product` p
                       '.Shop::addSqlAssociation('product', 'p').'
                       WHERE p.`id_product` = '.(int)$product->id);
                   $product->date_add = pSQL($datas['date_add']);
                   $res = $product->update();
               }
               // If no id_product or update failed
               if (!$res)
               {
                   if (isset($product->date_add) && $product->date_add != '')
                       $res = $product->add(false);
                   else
                       $res = $product->add();
               }
           }

Link to comment
Share on other sites

  • 6 months later...

I have problem like u, use this code and 

'id_product_pack' => array('label' => $this->l('Id_product_pack'))

, is empty - dont add id_product_pack 

 

how to add this for ps_pack (sql work ok)

INSERT INTO `ps_pack`(`id_product_pack`, `id_product_item`, `quantity`) VALUES (4,480,1)

Please help :)

Edited by ukwyspa (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...