Jump to content
Sign in to follow this  
Mauritron

Changing the -- Ignore -- option during import

Recommended Posts

Changing Import and the Ignore Feature.

My product details are kept on a database making it quick and easy
to change things.
However when I need to import the created .csv file 
I find that the CS import catalogue feature defaults to
-- Ignore --
for every field entry.
I need to go and change each one individually to match the import headings.
The headings I use in my DB / CSV are exactly the same as the ones on the CS suggested
list in the same order. 

Is it possible to bypass this option and automatically
select the matching field during the import.
There are 34 field options for the import and having to
select each one individually every time I do a full import
is annoying.

Cheers all


 

Share this post


Link to post
Share on other sites

Please try this:

In the admin skin template products.import.php

Find near line 68:

{foreach from=$COLUMNS item=column}<option value="{$column.column}">{$column.title}</option>{/foreach}

Change to:

{foreach from=$COLUMNS item=column}<option value="{$column.column}"{if $map.example eq $column.column} selected="selected"{/if}>{$column.title}</option>{/foreach}

 

Share this post


Link to post
Share on other sites

Thanks for your reply but no luck.
Checked and double checked to get the line exact.
Checked the spreadsheet headers are exactly as they should be.
Cleared history, cache etc still no luck.

 

Share this post


Link to post
Share on other sites

In the admin skin template products.import.php, at the very end of the file, add {debug}.

In admin, Import Catalogue, the browser will want to show a popup. Let it. This popup will not have anything of use in it.

Browse for a CSV file to be imported and click Save. The next page will also have a popup.

In the left pane, look for $COLUMNS. The list in the right pane should be the array comprising all the eligible database columns each CSV element can be associated with identified by their friendly descriptive name (such as: column => "name", title = "Product Name").

Then look for $MAPS. The list in the right pane should be the array read in as the first line of the CSV -- presumably the headers -- (such as: offset => "2", example => "name").

We are comparing the value for example with the value for column. If equal, set the "selected" attribute.

Since you edited a template, you may need to have CubeCart clear its cache (admin, Maintenance, Rebuild tab, Clear Cache).

 

Edited by bsmither

Share this post


Link to post
Share on other sites

Thanks so far. 
Everything matched and I followed it all until the part where you said

If equal, set the "selected" attribute.

Not sure on how this is done.
Please can you explain!

(I'm not a programmer of modern languages, last time I did any programming it was BASIC back in the 80's).
Anyway it's getting late over here in the UK so I'm in no rush.
Attached is a printout of the popup.
Many thanks.

Smarty Debug Console.pdf

Smarty Debug Console.pdf

Share this post


Link to post
Share on other sites
{foreach from=$COLUMNS item=column}<option value="{$column.column}"{if $map.example eq $column.column} selected="selected"{/if}>{$column.title}</option>{/foreach}

It's the <option> tag. This tag has a value attribute and a selected attribute. If an <option> tag has a selected attribute, the browser knows to show this option as the pre-selected choice.

Trying to get the attached file above says File Not Available. It could be the case that PDF's are not allowed but I do not know for sure.

I do not need to see the whole popup. PM sent.

Share this post


Link to post
Share on other sites

Ok, I see that you have the friendly names of the database columns as the CSV headers.

I hope you can change those headers.

I suggest using the database table actual column names:

'available','status','name','image','product_code','cat_id','description',
'description_short','manufacturer','price','sale_price','cost_price', etc

You can see the complete list of table column names in the admin /sources/products.import.inc.php file, lines 299-333.

If you cannot change the CSV headers, then try using this:

In the admin skin template products.import.php

Find near line 68:

{foreach from=$COLUMNS item=column}<option value="{$column.column}">{$column.title}</option>{/foreach}

Change to:

{foreach from=$COLUMNS item=column}<option value="{$column.column}"{if $map.example eq $column.title} selected="selected"{/if}>{$column.title}</option>{/foreach}

Note we are looking now to compare example with title.

  • Like 1

Share this post


Link to post
Share on other sites

Brilliant. Solved. Changed my headers to the ones matching the php and it works perfect.

Thanks very much for your excellent advice.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...