Jump to content

[SOLVED] Import custom fields through csv file


stuffedhippo

Recommended Posts

I have been looking for this for a while but can not find a details instruction.

 

As you can see from my attacment I have set up a few custom fields for me products. Thiese are working on the backend/front end as I wish. The problem I have is the customer hase around 9500 products and wants to upload this data in the CSV file.

 

I am sure this is possible and did come accrsss this posthttp://www.prestasho...uestion/#307274 but have not been able to get it to work. Has anyone got a more in-depth explanation?

 

Thanks

 

stuffedhippo

post-260366-0-55620700-1330360199_thumb.png

Link to comment
Share on other sites

I think you only need

  • classes/product.php
  • admin/tabs/AdminImport.php

In AdminImport.php you need to add your fields at line 184:

Just Like:

 'condition' => array('label' => $this->l('Condition')));

 

At Line 936

$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($........

you have to add your fields with

...(int)($info['default_on']), ($info['YOURFIELDNAME'])...

 

Watch out that you fit the addProductAttribute function in Product.php.

 

In Product.php go to line ~920

public function addProductAttribute...

and add your parameters in the right position

.., $yourfieldname, ...

 

Now edit the Array in the function

array('id_product' =>.....

add your field with

..., 'yourfieldname' => pSQL($yourfieldname),...

 

This works for me. At the csv import your have to choose your fields at import step 2 manually.

 

Wrote this down in 5 minutes, hope it helps anyway..

  • Like 2
Link to comment
Share on other sites

  • 5 months later...

Seriously? This is the "fix"? Modify the base code to support more fields?

 

The more I look into PrestaShop the less impressed I become.

 

ALL fields available to a product or category should be available at the time of import. Period. The fact that I have a "Ignore this column" setting means that I'm already 90% of the way there. Instead of defining each individual attribute that is "available" to be imported in bulk, the system should recursively read the attribute list based on the kind of import I'm doing (product versus category) and let me choose ALL of them.

 

Additionally, being able to label the fields in the import process means that I can have them OUT OF ORDER or not include all of them if I don't want to. Modifying the base code of the product is a TERRIBLE solution.

Link to comment
Share on other sites

  • 2 months later...

is this still the case with 1.5.1.0? i'm in admin creating features and attributes fuilly expecting them to show up in import list but they are not. I never expected in a million years that attributes i create for a product would not be importable. that's just common sense! am i missing something or do we still not have full import functionality even though we've got multi store? what is the point of csv import if i still have to go through the product admin filling in blanks.

 

please tell me i'm missing something! if not, how soon can this be implemented?

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
  • 3 weeks later...

Hi!

 

I'm using PS 1.6 and can't find

$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($........

controllers/admin/AdminImportcontroller.php

 

So I just adde my fields like

'condition' => array('label' => $this->l('Condition')));

but had no luck - CSV import in admin panel stopped working, Any ideas how to customize csv import in PS 1.6?

Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...

Hi!

 

I'm using PS 1.6 and can't find

$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($........

controllers/admin/AdminImportcontroller.php

 

So I just adde my fields like

'condition' => array('label' => $this->l('Condition')));

but had no luck - CSV import in admin panel stopped working, Any ideas how to customize csv import in PS 1.6?

 

Your field is wrong, it should be:

'condition' => array('label' => $this->l('Condition'));

and then my best guess is that you need to change public function productImport()

 

adding some lines to accept that field to populate the database... but i never managed to get it to work

 

for instance i did the following in productImport()

if (isset($product->your_custom_field)){
        $product->your_custom_field = $product->your_custom_field;
}

maybe i done it wrong but it seems to me that it would insert into database... well it didn't, so any help would be apreciated.

Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...

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