Add custom fields in review form

后端 未结 2 1016
耶瑟儿~
耶瑟儿~ 2021-01-07 09:40

I am looking forward to create a custom fields \'Email Id\' & One drop-down in Review form .

I have tried this one but not saving the data, its hows the fields o

相关标签:
2条回答
  • 2021-01-07 09:52

    Modify the Mage core class is a bit scary, which will be difficult to upgrade magento core class in the future. You can override the specific class by your own custom module (See module creator if you want to setup one)

    Module's config.xml, add the models rewrite in as below:

    <global>
        <models>
            <review_mysql4>
                <rewrite>
                    <review>[[Your Company]]_[[Your Module]]_Model_Review</review>
                </rewrite>
            </review_mysql4>
        </models>
        ...
    </global>
    

    And the specified class will extend from the Magento core class you want to override:

    class [[Your Company]]_[[Your Module]]_Model_Review
        extends Mage_Review_Model_Mysql4_Review
    {
        protected function _afterSave(Mage_Core_Model_Abstract $object)
        {
         .... 
        }
    }
    

    Ps. to add the new field in magento review_detail table:

    $installer = $this;
    $installer->startSetup();
    $installer->run("ALTER TABLE review_detail ADD COLUMN email VARCHAR(255) NULL");
    $installer->endSetup();
    
    0 讨论(0)
  • 2021-01-07 09:59

    Finally i have solved it... Open app\code\core\Mage\Review\Model\Resource\Review.php

    you will find this code in line about 150

    protected function _afterSave(Mage_Core_Model_Abstract $object)
    {
    $detail = array(
    'title' => $object->getTitle(),
    'detail' => $object->getDetail(),
    'nickname' => $object->getNickname(),
    );
    

    Add the new two fields you want to add.

    protected function _afterSave(Mage_Core_Model_Abstract $object)
    {
    $detail = array(
    'title' => $object->getTitle(),
    'detail' => $object->getDetail(),
    'nickname' => $object->getNickname(),
    'email' => $object->getEmail(), // New field 1
    'fname' => $object->getFname(), // New field 2
    );
    

    Thats it no more.... :) Happy coding

    0 讨论(0)
提交回复
热议问题