What I'm trying to do is change the prices of products in a certain category. We get recommended retail prices from our supplier, but sometimes they do not work for us. Therefore, we need to take the cost of the product and, for example, add 20% to the product, so .. just enough cost = cost + 0.2 * cost. Now I need to do this on all products in the selected category, so here's what I still have ...
$category = Mage::getModel('catalog/category')->load(189);
$products = Mage::getModel('catalog/product')
->getCollection()
->addCategoryFilter($category)
->addAttributeToSelect('id');
foreach($products as $product) {
$cost = $db->fetchRow("SELECT value FROM `m_catalog_product_entity_decimal` WHERE entity_id='" . $product->getId() . "' AND attribute_id='68'");
$cost = $cost['value'];
$newCost = $cost + $cost*$percentage;
$db->query("UPDATE `m_catalog_product_entity_decimal` SET value='$newCost' WHERE entity_id='" . $product->getId() . "' AND attribute_id='64'");
}
SQL, php- magento ( Magento 1.4 ). "id" , . , SQL- , . 10 , , 500 .
SQL- foreach . - 68, - 64. .
Magento EAV . , , "" "", m_catalog_product_entity_decimal
,
value_id entity_type_id attribute_id store_id entity_id value
6401 4 64 0 2184 399.9500
_id - , entity_type_id 4 , . attribute_id . 64 _id "". Store_id . Entity_id - , - .