这是我第一次与Magento合作。我必须准备模块,将选择字段(是/否)添加到常规信息(管理面板中的类别)。我已经完成了这部分。下一步是检查用户进入类别侧时在常规信息表格中选择的值。如果用户没有登录并且通用信息表单中的管理员选项选择为“是”,则系统应显示如下信息:“您必须登录”。Magento - 在前端和后端之间传递数据
Below my folder structure:
- app
-> code
-> community
-> AttributeCategory
->CustomAttributeCategory->
- etc
-> config.xml
<?xml version="1.0"?>
<config>
<modules>
<AttributeCategory_CustomAttributeCategory>
<version>0.0.3</version>
</AttributeCategory_CustomAttributeCategory>
</modules>
<global>
<resources>
<add_category_attribute_login>
<setup>
<module>AttributeCategory_CustomAttributeCategory</module>
<class>Mage_Catalog_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</add_category_attribute_login>
<add_category_attribute_login_write>
<connection>
<use>core_write</use>
</connection>
</add_category_attribute_login_write>
<add_category_attribute_login_read>
<connection>
<use>core_read</use>
</connection>
</add_category_attribute_login_read>
</resources>
</global>
</config>
- sql -> add_category_attribute_login ->
- mysql4-install-0.0.3.php :
<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'is_category_allowed', [
'group' => 'General Information',
'type' => 'int',
'input' => 'select',
'label' => 'required logged-in user',
'sort_order' => 1000,
'visible' => true,
'required' => true,
'source' => 'eav/entity_attribute_source_boolean',
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'option' => [
'values' => [
0 => 'No',
1 => 'Yes',
]
],
]);
$this->endSetup();
AND
- app->etc->modules:
AttributeCategory_CustomAttributeCategory.xml:
<?xml version="1.0"?>
<config>
<modules>
<AttributeCategory_CustomAttributeCategory>
<active>true</active>
<codePool>community</codePool>
</AttributeCategory_CustomAttributeCategory>
</modules>
</config>
请告诉我如何在用户访问类别页面时检查前面的值?