Magento - 在前端和后端之间传递数据

时间:2016-08-14 14:51:38

标签: php xml magento magento-1.9

这是我第一次和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>

请告诉我如何在用户访问类别页面时检查前面的值?

0 个答案:

没有答案