我为我的产品使用自定义属性,我正在处理我的脚本,它获取属性并在更改它们之后。我已经完成了选择代码,但我不知道如何进行代码更改代码。
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::app('default');
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('manufacturer', '3')
->addAttributeToSelect('*');
foreach ($collection as $product) {
echo $product->getName();
echo $product->getResource()->getAttribute('cena_balenia_czk')->getFrontend()->getValue($product);
echo '-';
echo $product->getResource()->getAttribute('czk')->getFrontend()->getValue($product);
echo '<br>';
}
?>
答案 0 :(得分:2)
看看下面的代码:
<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::app('default');
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('manufacturer', '3')
->addAttributeToSelect('*');
foreach ($collection as $product) {
$product->setName('NEW PROUDUCT NAME');
$product->setCenaBaleniaCzk(999);
$product->setCzk('NEW Czk VALUE');
$product->save(); // This line is extremely important to commit your changes
}
?>