Найдено, где данные хранятся в базе данных и только что закончили тем, что непосредственно изменили базу данных.
$ groupsDisabledArray - это массив, содержащий идентификатор для каждой группы. Я хочу отключить права продукта. Данные в Magento просто хранится в виде разделенных запятыми группы идентификаторов
Пример:
1,2,3,4,5,6,7,8,9,10
Я взрываться отключил группу массива мой идентификатор, чтобы получить разделенный запятыми список
$groupsList=implode(",", $groupsDisabledArray);
Тогда либо вставьте или обновите таблицу catalog_product_entity_text, где хранится значение.
Значение хранится в catalog_product_entity_text где
entity_id = PRODUCT_ID
attribute_id = 155 (This corresponds to the table eav_attribute where attribute_code = 'aw_cp_disable_product')
entity_type_id = 4 (This corresponds to table eav_entity_type where entity_type_code = 'catalog_product')
store_id = STORE_ID (If you just have one store you should just be able to put 0 here for the Default Store)
код, чтобы сделать полное обновление ниже. Может потребоваться обновить путь до Mage.php в зависимости от того, где вы помещаете свой скрипт.
include("/app/Mage.php");
/* Get DB Connections */
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
$tableName = $resource->getTableName('catalog_product_entity_text');
/* $groupsDisabledArray - Array of all of the Magento Group ID's I want to disable this product for */
$groupsList=implode(",", $groupsDisabledArray);
$sql="SELECT * FROM $tableName WHERE entity_id=$product_id AND attribute_id=155 and entity_type_id=4 AND store_id=0;";
$results = $readConnection->fetchAll($sql);
if (count($results) > 0) {
$sql="UPDATE $tableName SET value='$groupsList' WHERE entity_id=$product_id AND attribute_id=155 and entity_type_id=4 AND store_id=0;";
}
else
{
$sql="INSERT INTO $tableName (entity_id, entity_type_id, store_id, attribute_id, value) VALUES ($product_id, 4, 0, 155, '$groupsList')";
}
$writeConnection->query($sql);