Как обновить значение поля атрибута с помощью запроса mysql?


Мне нужно обновить атрибут "search_sku". Я должен обновить этот атрибут, используя артикул. Я выполнил эту работу с помощью mysql. Но я не понимаю, как я могу получить этот запрос?

Пожалуйста, помогите мне. Заранее благодарю!

Author: Prashant Parekh, 2013-10-04

1 answers

/**
 * 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);
 3
Author: Stefan Gregori, 2014-05-28 12:31:42