how in Magento 1.7 we can apply tax class to all products via SQL
Below is sql query which i hope that i need to run to get this done

 UPDATE `catalog_product_entity_int` SET `value` =2 WHERE `attribute_id` =81;

i am unable to find attribute id for for tax class attribute? Any help on this

or i am also open to entirely different solution

4 Answers 4


Log in to your admin panel, then select

Catalog->Manage Products

Then you can click Select All, and from the Actions drop down on the right, choose Update Attributes.

Here you can choose the tax class and update all products in one go.

enter image description here

  • tax class id attribute isn't available in this method Apr 2, 2014 at 9:18
  • I've added a screenshot to the answer. If you can't see this, then I would imagine that you're selecting a product/s that are a part of an attribute set where tax_class has been removed. In which case, you need to address that first. Apr 2, 2014 at 9:42
  • 1
    Is the possible apply tax by SKU wise?
    – user51361
    Jun 22, 2017 at 5:26

You can do it by code: Create a file called taxclass.php on the same level as index.php with the following content.

error_reporting(E_ALL | E_STRICT);
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
ini_set('display_errors', 1);

$productIds = Mage::getResourceModel('catalog/product_collection')->getAllIds();

    array('tax_class_id' => 2),

If you still want to do it in a query you can identify the tax class attribute like this:

    attribute_code = 'tax_class_id' AND
    entity_type_id = (SELECT entity_type_id FROM eav_entity_type where entity_type_code = 'catalog_product')

then run your update with the attribute id your find. But this won't work if you have products that don't have a class id set.

  • to do this via code where should i put that code overide ? Apr 2, 2014 at 9:17
  • You can put the code in one of the upgrade scripts of any module you create, or you can put it in a simple php file and run that in the browser. See my update to the answer
    – Marius
    Apr 2, 2014 at 9:29
  • Very nice :) This is a very neat way. Apr 11, 2016 at 9:22
  • Which one is best frist or second ? Dec 25, 2017 at 7:35
  • @SaurabhJain Neither. Better use the accepted answer. But if you want to do it via code, better use first one to avoid direct queries.
    – Marius
    Dec 25, 2017 at 8:10

Open Magento admin, Go to the catalog manage products section. Then click on select all and go to mass action dropdown and selection update attribute and apply.

Then a new window will open then apply changes in text class attribute.


To find attribute ID

  1. In your database and find your eav_attribute table execute below query

    SELECT * FROM eav_attribute WHERE attribute_code LIKE 'tax_class_id'

  2. You can get attribute id by above sql query

  3. By using that you can execute this sql

    UPDATE catalog_product_entity_int SET value =2 WHERE attribute_id = your_attribute_id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.