1

I am using Event catalog_category_save_after. In observer fetch query is working fine but insert and delete query is not working.

Below is my code :

  $resource = Mage::getSingleton('core/resource');
  $readConnection = $resource->getConnection('core_read');
  $writeConnection = $resource->getConnection('core_write');
  $tableName = $resource->getTableName('catalog_category_product');

  $query = 'INSERT INTO ' . $tableName .' (`category_id`,`product_id`,`position`)VALUES("215","33702","5");';
  $test1 = $writeConnection->query($query);

Below querey is generating:

INSERT INTO catalog_category_product (`category_id`,`product_id`,`position`)VALUES("215","33702","5");

Can anyone help me in this?

0

I too faced the same issue.

Using catalog_category_save_commit_after instead of catalog_category_save_after did the trick for me.

Alternatively, you can try to use the Magento methods to insert the new row rather than running direct SQL. It should work fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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