Magento – bulk apply (or csv import) fixed product tax

csvimport

I have a csv file with more than 400 items to import.

All the attributes are imported fine except for the fixed product tax (that is the same for all products).

I tried to manually create one on a product and to export it, but nothing appears in the generated csv.

Is there a way to add it in the csv, or to manually trigger it on all products?

Best Answer

TopperH, You have probably manually edited your 400 products and no longer need this but this is provided for future reference, since it was all new to me.

I went thru the process of setting up a flat tax attribute of recycle, added it to products and tried to export. I got the header in the csv as you did but no values for the tax.

Look in the table mage_weee_tax for the entries you have entered already (mage_ is my prefix) WEEE = waste of electrical and electronical equipment.

I created a recycle_fee attribute (my entity 137) and added this to default attribute group and then set it in two of my three products in Manage Products: US california for one and Angola for the other to stand out in a search of the db dump. that is values 1 & 2 below Then I added two more states to product with entity "2" and it removed value_id 1 and added 3, 4 & 5 CA = 12 & etc from mage_directory_country_region And I changed the value of value_id 2 from 6.00 to 4.00 to 2.00 and it removed value_id 2 and added 6 removed 6 and added 7

value_id, website_id, entity_id, country, value, state, attribute_id, entity_type_id
    1   0   2   US  4.0000  12  137     4
    2   0   3   AO  6.0000  *   137     4
    3   0   2   US  4.0000  12  137     4
    4   0   2   US  3.0000  43  137     4
    5   0   2   US  2.0000  13  137     4
    6   0   3   AO  4.0000  *   137     4
    7   0   3   AO  2.0000  *   137     4

The effect is that the saving of any change to a products fixed product tax removes all records for that product and adds all them all as new records.

So how does this help you? Depends on where you are in the process and the complexity of these taxes. If your 400 items all have the same tax country and state and you have the entity_id of your product you could directly update or import into this table.

I tested this on test products and a test database. I changed records so each product had only one entry US and one state 12 for California and it displayed correctly in the Manage Product page

If you have only the sku you'll have to get the entity_id ...

<?php
error_reporting(E_ALL | E_STRICT);
require_once '../ohs1/app/Mage.php';
$app = Mage::app();
Mage::register('isSecureArea', true);

$file = 'skus_ids.csv';
$csv = new Varien_File_Csv();
$headdata = array();

$headdata['id'] = 'id' ;
$headdata['sku']  = 'sku';

$csvdata = array();
$csvdata[] = $headdata;
$products = Mage::getModel('catalog/product')->getCollection();

foreach ($products as $product) 
{
    $product_data = array();
    $product_data['id'] = $product->getId();
    $product_data['sku'] = $product->getSku();

    $csvdata[] = $product_data;
}

$csv->saveData($file, $csvdata);

And use this to import back into the weee_tax table.

Related Topic