【问题标题】:change position of category attribute in General information in magento在magento的一般信息中更改类别属性的位置
【发布时间】:2014-05-23 07:46:21
【问题描述】:

如何根据需要向上或向下更改类别中的属性位置?

【问题讨论】:

  • 简短描述是您的自定义属性吗?
  • 是的,我想更改简短描述的位置。它位于描述属性之前。
  • 如果 short_description 是您的自定义属性,那么您可以通过定义其排序顺序来更改其位置
  • 你能显示你必须创建简短描述属性的代码
  • $this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'short_description', array('group' => '一般信息', 'label' => '简短描述', 'input' => 'textarea', 'type' => 'text', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'visible' => true, 'required' => false, 'user_defined' => true, 'wysiwyg_enabled' => true , 'is_visible_on_front' => true, 'is_html_allowed_on_front' => true, 'default' => '' ));

标签: php magento magento-1.4


【解决方案1】:

这是一种丑陋的做法,但我没有别的办法。

属性组中的属性位置保存在eav_entity_attribute 表中。
首先,您需要确定属性short_description 的ID。

这里是那个查询。

SELECT 
    attribute_id, attribute_code
FROM 
    eav_attribute 
WHERE
    attribute_code = 'short_description' AND
    entity_type_id = (SELECT 
                          entity_type_id
                      FROM
                          eav_entity_type
                      WHERE 
                          entity_type_code = 'catalog_category'
                     ) 

假设你得到的属性 id 是100

然后你需要获取应该在你的属性之上和之下的属性的属性id。

使用上述相同的查询,但将属性代码从 short_description 更改为 is_anchordescription

假设is_anchor 的值为 10,description 的值为 15。

然后查看它们在属性集中的位置。

SELECT * FROM `eav_entity_attribute` where `attribute_id` in (10, 15, 100);

查看sort_order 字段。
假设你有这样的东西:

attribute_id|sort_order
10          | 40            //is_anchor attribute
15          | 50            //description attribute
100         | 120           //shot_description attribute

您现在只需将 short_description 属性的 sort_order 更新为介于 is_anchor 和 description 的值之间。
在上面的示例中,您将需要 45

UPDATE `eav_entity_attribute` set `sort_order` = 45 where `attribute_id` = 100

【讨论】:

  • @ParagDave。很可能它可以通过安装脚本来完成,但我不知道如何。这就是为什么我写了这个丑陋的解决方案。
  • Marius,在安装脚本中,指定'sort_order' => 45,
【解决方案2】:

后端分类页面由以下文件呈现:

app/design/adminhtml/default/default/template/catalog/category    
app/code/core/Mage/Adminhtml/Block/Catalog/Category

但它很复杂,而且里面还有很多 javascript。

【讨论】:

  • 产品属性是正确的,但是我想改变类别属性的顺序。
【解决方案3】:

您可以通过更新脚本实现此目的

$installer->run("
    update {$installer->getTable('eav_entity_attribute')} set `sort_order`=1 where `attribute_id`=(select `attribute_id` from {$installer->getTable('eav_attribute')} where `attribute_code`='short_description');
");

如果排序顺序不正确,请尝试将 sort_order 值设置为 0,或者作为最后的手段,也更改其他属性的 sort_order 值。

【讨论】:

    【解决方案4】:

    有些事情不用进入代码就可以解决:)

    只是: 1. 进入您的目录/属性/管理属性集/您的属性集。 2.将属性拖放到您想要的位置 3. 保存你的属性集

    【讨论】:

    • 该问题与管理区域中的类别字段有关,与产品属性无关。
    猜你喜欢
    • 2021-02-24
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-25
    • 2014-05-21
    相关资源
    最近更新 更多