2

ihave problem again with my rewrite, i tried create rewrite model on my lesson app/code/local/Lesson/Test/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Lesson_Test>
            <version>1.0.0</version>
        </Lesson_Test>
    </modules>

    <global>
        <models>
            <customer>
                <rewrite>
                    <product>Lesson_Test_Model_Customer</product>
                </rewrite>
            </customer>
        </models>
    </global>
</config>

app/code/local/Lesson/Test/Model/Customer.php

<?php
class Lesson_Test_Model_Customer  extends Mage_Customer_Model_Customer
{
    public function getName()
    {
        $name = '';
        if ($this->getPrefix()) {
            $name .= $this->getPrefix() . ' ';
        }
        $name .= $this->getFirstname();
        if ($this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        }
        $name .=  ' ' . $this->getLastname();
        if ($this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        }
        return $name.'22222222';
    }
}

app/etc/modules/Lesson_all.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Lesson_Test>
            <active>true</active>
            <codePool>local</codePool>
        </Lesson_Test>
    </modules>
</config>

i try access

http://127.0.0.1/magento/index.php/lesson 
http://127.0.0.1/magento/index.php/customer/customer
http://127.0.0.1/magento/index.php/customer/product
http://127.0.0.1/magento/index.php/lesson/customer/customer
http://127.0.0.1/magento/index.php/lesson/customer/product

the all of this is Whoops, our bad..., thank you :)

4
  • 1
    Try this url: http://127.0.0.1/magento/index.php/customer/account Jun 7, 2016 at 3:33
  • thanks @AdarshKhatri but it still not work
    – gufran
    Jun 7, 2016 at 3:41
  • what you want? want to rewrite model class or controller clasa?
    – Amit Bera
    Jun 7, 2016 at 3:41
  • i want rewrite model
    – gufran
    Jun 7, 2016 at 4:06

1 Answer 1

6

As per as, your code you want to rewrite class Mage_Customer_Model_Customer.

But in config.xml, you try to rewrite model class Mage_Customer_Model_Product and in default magento this class does not exist. I sure you want to rewrite class Mage_Customer_Model_Customer. So, you should

Change

<product>Lesson_Test_Model_Customer</product>

to

 <customer>Lesson_Test_Model_Customer</customer>

at config.xml

4
  • thank you @Amitbera, but i dont look something happen if i access http://127.0.0.1/magento/index.php/customer/account like @AdarshKhatri said, i can't look 22222222 message
    – gufran
    Jun 7, 2016 at 5:22
  • you have loggedin at system or not?when $Customer->getName() will called then it see the result
    – Amit Bera
    Jun 7, 2016 at 5:28
  • yes i login on system, on contact information i look this message Contact Information Edit gufran efendi loves Magento [email protected] Change Password i think a can look some message like gufran efendi 2222222 loves Magento
    – gufran
    Jun 7, 2016 at 5:33
  • hoho i'm so stupid, i have a duplicate file about rewrite model, i delete other file and it working, thanks @Amitbera :)
    – gufran
    Jun 7, 2016 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.