Jump to content

[SOLVED]Customize IMPORT / EXPORT xls


Reco-X

Recommended Posts

Maybe it helps if you can give an example of the extra fields (their value, their 'meaning' in words, any known 'match' with Prestashop Product attribute(i.e. where exactly INSIDE a product do you want it to be stored after import etc)

 

Please add an example of your CSV rows.

 

What PrestaShop version do you use?

pascal

Link to comment
Share on other sites

  • 2 months later...
My version is 1.5.4.1 but i can change for the last one because the site isn't still in production.

Many improvement and many fix in the last version PS

https://github.com/PrestaShop/PrestaShop/archive/development.zip

 

i know i must modify the file controlers/admin/adminimportcontroller.php but i don't know where exactly.
			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 excluded')),
					'price_tin' => array('label' => $this->l('Price tax included')),
					'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')),
					'width' => array('label' => $this->l('Width')),
					'height' => array('label' => $this->l('Height')),
					'depth' => array('label' => $this->l('Depth')),
					'weight' => array('label' => $this->l('Weight')),
					'quantity' => array('label' => $this->l('Quantity')),
					'minimal_quantity' => array('label' => $this->l('Minimal quantity')),
					'visibility' => array('label' => $this->l('Visibility')),
					'additional_shipping_cost' => array('label' => $this->l('Additional shipping cost')),
					'unity' => array('label' => $this->l('Unity')),
					'unit_price_ratio' => array('label' => $this->l('Unit price ratio')),
					'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)')),
					'available_date' => array('label' => $this->l('Product available date')),
					'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:Customized)')),
					'online_only' => array('label' => $this->l('Available online only (0 = No, 1 = Yes)')),
					'condition' => array('label' => $this->l('Condition')),
					'customizable' => array('label' => $this->l('Customizable (0 = No, 1 = Yes)')),
					'uploadable_files' => array('label' => $this->l('Uploadable files (0 = No, 1 = Yes)')),
					'text_fields' => array('label' => $this->l('Text fields (0 = No, 1 = Yes)')),
					'out_of_stock' => array('label' => $this->l('Action when out of stock')),
					'advanced_stock_management' => array('label' => $this->l('Advanced stock management')),
					'original_name' => array('label' => $this->l('Original name')),
					'actors' => array('label' => $this->l('Actors')),
					'director' => array('label' => $this->l('Director')),
					'duration' => array('label' => $this->l('Duration')),
					'country' => array('label' => $this->l('Country')),
					'year' => array('label' => $this->l('Year')),
					'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, the default shop will be used.'),
					)
				);

You have to add in classes/Product.php

class ProductCore extends ObjectModel

    /**
     * @since 1.5.7
     * @var string for movie
     */
    public $original_name;
    public $actors;
    public $director;
    public $duration;
    public $country;
    public $year;
    public static $definition = array(

            /* Movie fields */
            'original_name' =>                 array('type' => self::TYPE_STRING, 'validate' => 'isString'),
            'actors' =>                     array('type' => self::TYPE_STRING, 'validate' => 'isString'),
            'director' =>                     array('type' => self::TYPE_STRING, 'validate' => 'isString'),
            'duration' =>                     array('type' => self::TYPE_STRING, 'validate' => 'isString'),
            'country' =>                      array('type' => self::TYPE_STRING, 'validate' => 'isString'),
            'year' =>                         array('type' => self::TYPE_STRING, 'validate' => 'isString'),


add to you csv file

post-459329-0-96206500-1383409622_thumb.png

Original name Actors Director Duration Country Year

Sleepy Hollow Johnny Deep Tim Burton 190 EN 20001231

Edited by indesign (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Yes it work perfectly, also i have created an override for all the classes and controllers who i modified.

 

 

I show the examples:

<?php
Class Product extends ProductCore
{
	/*** @var string for movies */
	public $original_name;
	public $actors;
	public $director;
	public $duration;
	public $country;
	public $year;
	
	
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        self::$definition['fields']['actors'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255);
        self::$definition['fields']['director'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255);
        self::$definition['fields']['original_name'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255);
        self::$definition['fields']['duration'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255);
        self::$definition['fields']['country'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255);
      	self::$definition['fields']['year'] = array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'size' => 4);
        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }
     
}
?>	
<?php
class AdminImportController extends AdminImportControllerCore
{
	public function __construct()
	{
		parent::__construct();
		$this->available_fields += array(
			'original_name' => array('label' => $this->l('Nombre Original')),
			'actors' => array('label' => $this->l('Actores')),
			'director' => array('label' => $this->l('Director')),
			'duration' => array('label' => $this->l('Duracion')),
			'country' => array('label' => $this->l('Pais')),
			'year' => array('label' => $this->l('Año'))
		);
	}
}
?>

And here is a very good tutorial who helps a lot.

http://nemops.com/extending-prestashop-objects/#.UuglirTfNEY


 

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