Export / Import Option Settings

Can we import and export option settings…???

Need to set it for over 20,000 products…



Aren't options part of the standard product export? Not sure if global options are included, but I'm almost certain that non-global options are included when 'Options' is in the Exported fields.



Oops, re-reading, it seems you're discussing the option rules from the product. For that, I don't know. Might try selecting everything and looking at the results.

[quote name='tbirnseth' timestamp='1427869589' post='209793']

Oops, re-reading, it seems you're discussing the option rules from the product. For that, I don't know. Might try selecting everything and looking at the results.

[/quote]



Yup, Tried that… Not in the standard export… Now trying to figure out where in the database its stored… And go that route…

Unbelievable how stuff just gets left out of basic functions (Import/Export)… ie, reward pints, promo text, etc…

tried it last week, then thought about seeing where in the code is the setting to set as default before importing to have sequential/allowed as normal setting but not started yet.

Was hoping this could be toggled between imports

[color=#282828][font=arial, verdana, tahoma, sans-serif]/app/addons/my_changes/schemas/exim/products.post.php[/font][/color]

$schema['export_fields']['Options type'] = array (
'db_field' => 'options_type',
);

$schema['export_fields']['Exceptions type'] = array (
'db_field' => 'exceptions_type',
);

return $schema;

[quote name='The Tool' timestamp='1427912158' post='209906']

[color=#282828][font=arial, verdana, tahoma, sans-serif]/app/addons/my_changes/schemas/exim/products.post.php[/font][/color]

$schema['export_fields']['Options type'] = array(
'db_field' => 'options_type',
),
$schema['export_fields']['Exceptions type'] = array(
'db_field' => 'exceptions_type',
);

return $schema;


[/quote]



That worked perfect… Thank You,… Saved me tons of time…



Now not to be a total pain… Is it possible to do the same for “Forbidden Combinations” ??

That one is a little tougher since I don't use options and I am not sure what kind of data is stored. What kind of data is stored for Forbidden Combinations?

Here is what I got so far in my products.post.php


```php

$schema['export_fields']['Promo text'] = array (
'table' => 'product_descriptions',
'db_field' => 'promo_text',
);
$schema['export_fields']['Options type'] = array(
'db_field' => 'options_type',
);
$schema['export_fields']['Exceptions type'] = array(
'db_field' => 'exceptions_type',
);
$schema['export_fields']['Options Exceptions'] = array(
'table' => 'product_options_exceptions',
'db_field' => 'combination',
);
return $schema;
```

Here is what is stored in the combination field that needs exported..
```php
a:4:{i:835;s:2:"-1";i:836;s:4:"3434";i:838;s:4:"3440";i:837;s:2:"-1";}
```

The error I am getting is:
[b]Error[/b]Invalid pattern definition: missing table references

The error is coming from my attempt at exporting the combination field.

What am I doing wrong..

After looking at this further it looks like I will have to do it thru the database… Since I have 2 Forbidden Combinations per product it creates 2 entries in the data base per product. Why can it never be easy…



Thanks Again Tool for the code…

Yep, I figured that one was going to be a little more complicated.

[quote name='CarStickersDecals' timestamp='1427917800' post='209921']

After looking at this further it looks like I will have to do it thru the database… Since I have 2 Forbidden Combinations per product it creates 2 entries in the data base per product. Why can it never be easy…

[/quote]



It is required to create a new PHP function which will get data from database and convert it to the required format. The code should be similar to this:


```php

$schema['export_fields']['Promo text'] = array (
'table' => 'product_descriptions',
'db_field' => 'promo_text',
);
$schema['export_fields']['Options type'] = array(
'db_field' => 'options_type',
);
$schema['export_fields']['Exceptions type'] = array(
'db_field' => 'exceptions_type',
);
$schema['export_fields']['Options Exceptions'] = array(
'process_get' => array('fn_export_options_exceptions', '#key'),
'linked' => false,
'export_only' => true
);

function fn_export_options_exceptions($product_id)
{
... GET DATA AND CONVERT TO THE REQUIRED FORMAT HERE...
return $data;
}

return $schema;
```

[quote name='eComLabs' timestamp='1427987505' post='210077']

It is required to create a new PHP function which will get data from database and convert it to the required format. The code should be similar to this:


```php

$schema['export_fields']['Promo text'] = array (
'table' => 'product_descriptions',
'db_field' => 'promo_text',
);
$schema['export_fields']['Options type'] = array(
'db_field' => 'options_type',
);
$schema['export_fields']['Exceptions type'] = array(
'db_field' => 'exceptions_type',
);
$schema['export_fields']['Options Exceptions'] = array(
'process_get' => array('fn_export_options_exceptions', '#key'),
'linked' => false,
'export_only' => true
);

function fn_export_options_exceptions($product_id)
{
... GET DATA AND CONVERT TO THE REQUIRED FORMAT HERE...
return $data;
}

return $schema;
```
[/quote]

Thanks eComLabs for your input... But we don't need the data converted.. Just need to export and import the raw data.
We only use global options so the same forbidden combination (quantity-2) will be applied to all 20,000 plus products..

Or I could have no idea what I'm talking about.. Not the first time... LOL..

I believe (trying not to put words in another's mouth) that when he says “required format” he means to unserialize the data and then provide that info in a manner that is suitable for a CSV field. Then you would need the inverse on the import side - the ability to read the CSV format and then serialize up the data and apply it to the DB.

[quote name='tbirnseth' timestamp='1427997968' post='210088']

I believe (trying not to put words in another's mouth) that when he says “required format” he means to unserialize the data and then provide that info in a manner that is suitable for a CSV field. Then you would need the inverse on the import side - the ability to read the CSV format and then serialize up the data and apply it to the DB.

[/quote]



I see… Long story short… “Not Going to Happen”



One would think this is a basic feature that cs-cart should already have…

So you truly cannot bulk edit products in their entirety…

[quote name='tbirnseth' timestamp='1427997968' post='210088']

I believe (trying not to put words in another's mouth) that when he says “required format” he means to unserialize the data and then provide that info in a manner that is suitable for a CSV field. Then you would need the inverse on the import side - the ability to read the CSV format and then serialize up the data and apply it to the DB.

[/quote]



Right. I do not remember the correct structure of the product_options_exceptions table, but the function can be:



function fn_export_options_exceptions($product_id)
{
return db_get_field("SELECT combination FROM ?:product_options_exceptions WHERE product_id = ?i", $product_id);
}

How to export purchased products in 4.3.5?

How to export purchased products in 4.3.5?

What do you mean by purchased products? You want to skip products which were not sold at all?

What do you mean by purchased products? You want to skip product which were not sold at all?

When I select all new orders and choose View Purchased Products it opens another page with all products within selected orders. After that I select all those products and choose Export selected and it opens Export Data page on products tab dispatch=exim.export§ion=products&pattern_id=products&page=1 but there is no option to add to exported fields the purchased qty of products.

When I select all new orders and choose View Purchased Products it opens another page with all products within selected orders. After that I select all those products and choose Export selected and it opens Export Data page on products tab dispatch=exim.export§ion=products&pattern_id=products&page=1 but there is no option to add to exported fields the purchased qty of products.

OK. I got it. Please try the following code

 array('fn_export_purchased_amount', '#key'),
	'linked' => false,
	'export_only' => true
);

function fn_export_purchased_amount($product_id)
{
return db_get_field(“SELECT SUM(amount) FROM ?:product_sales WHERE product_id = ?i”, $product_id);
}

return $schema;

(!) Not tested

Thank you eComLabs but I think the database is wrong, it must be cscart_order_details because purchased products must be from selected orders.