gpt4 book ai didi

php - 在 Magento 1.7.2 中使用 MYSQL 查询插入相同的产品描述

转载 作者:行者123 更新时间:2023-11-29 13:21:57 25 4
gpt4 key购买 nike

向所有程序员致敬!

我已经创建了 1000 个带有脚本但没有描述的产品。

我想使用 MYSQL 查询在所有产品中插入相同的产品描述。

(我认为表:Catalog_product_entity_text 存储产品的描述)

您能告诉我在我的所有产品中插入相同产品描述的查询吗在 MYSQL 中?

最佳答案

由于其 EAV 结构和涉及的所有数据过滤,直接将数据插入到 magento 中的 MYSQL 表中被认为是危险的,最好的方法是在 magentoroot/shell 中创建一个 shell 脚本并在那里保存所有描述,以下代码片段可能是帮助

require_once 'abstract.php';


class Mage_Shell_ProductUpdate extends Mage_Shell_Abstract
{


public function run()
{
$productCollection = Mage::getModel('catalog/product')->getCollection();
foreach($productCollection as $product) {
$product->load();
try {

$product->setDescription('YOUR DESCRIPTION');
$product->save();

} catch(Exception $e) {
print "\n{$e->getMessage()}\n";
}
}

}
}
$shell = Mage_Shell_ProductUpdate();
$shell->run();

关于php - 在 Magento 1.7.2 中使用 MYSQL 查询插入相同的产品描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20692267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com