1

I have to update attribute "search_sku". I have to update this attribute using sku. I have do this job using mysql. But I am not getting that how can I get this query?

Please help me. Thanks in advanced!

1
  • 1
    I am not sure what you are asking here. Have you a custom product attribute called "search_sku"? What is it used for? Why do you need it updating and is this a one off update or does it need to up regular? Commented Oct 4, 2013 at 14:15

1 Answer 1

3

/**
 * Get the resource model
 */
$resource = Mage::getSingleton('core/resource');

/**
 * Retrieve the write connection
 */
$writeConnection = $resource->getConnection('core_write');

/**
 * Retrieve our table name
 */
$table = $resource->getTableName('catalog/product');

/**
 * Set the product ID
 */
$productId = 44;

/**
 * Set the new SKU
 * It is assumed that you are hard coding the new SKU in
 * If the input is not dynamic, consider using the
 * Varien_Db_Select object to insert data
 */
$newSku = 'new-sku';

$query = "UPDATE {$table} SET sku = '{$newSku}' WHERE entity_id = "
         . (int)$productId;

/**
 * Execute the query
 */
$writeConnection->query($query);

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.