Magento:在类别中为什么 setName 不起作用

发布于 2024-12-15 09:22:32 字数 496 浏览 2 评论 0原文

我有两个关于 Magento 类别命名的问题。

  1. 因为我必须更改一堆类别的名称,所以我写了以下内容:

    $category = Mage::getModel ( '目录/类别' );
    $tree = $category->getTreeModel();
    $tree->load();
    
    $ids = $tree->getCollection()->getAllIds();
    
    如果($ids){
           foreach ( $ids 为 $id ) 
              if ($change[$id] != "") {
                    $_category->setName($change[$id]);
                    $_category->save();
            }
    }
    

    但这不会保存类别的名称?

  2. 我可以更改“默认类别”的名称吗?

I have two questions about Magento category naming.

  1. as I have to change the name of bunch of categories, I have written this:

    $category = Mage::getModel ( 'catalog/category' );
    $tree = $category->getTreeModel ();
    $tree->load ();
    
    $ids = $tree->getCollection ()->getAllIds ();
    
    if ($ids) {
           foreach ( $ids as $id ) 
              if ($change[$id] != "") {
                    $_category->setName($change[$id]);
                    $_category->save();
            }
    }
    

    But this does not save the name of the categories?

  2. Can I change the name of the "Default Category"?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉梦枕江山 2024-12-22 09:22:32

TheVyom 在他自己的问题中提供了这个答案:

由于我不在 ADMIN 商店中,因此对类别所做的更改没有得到反映。为了解决这个问题,我需要添加

require_once '../app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

TheVyom provided this answer in his own question:

As I was not in the ADMIN Store, the changes being made the the categeory was not being reflected. To fix this, I needed to add

require_once '../app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文