سؤال

I have override customer resource module in custom module. Like : Core_Mage_Model_Resource_Customer Override this module but not succeed. I have follow these steps : Here is config.xml

<?xml version="1.0"?>
<config>
    <modules>
       <Abc_CustomizeCustomers>
       <version>0.1.0</version>
       </Abc_CustomizeCustomers>
    </modules>
    <global>
       <customer_re>
          <rewrite> 
            <customer_resource> Abc_CustomizeCustomers_Model_Resource_Customer</customer_resource>
          </rewrite>
       </customer_re>
    </global>
</config> 

Here is Customer.php

 <?php
    class Abc_CustomizeCustomers_Model_Resource_Customer extends 
      Mage_Eav_Model_Entity_Abstract
     {
         protected function _beforeSave(Varien_Object $customer)
         {
             Mage::log("checkCustomer", null, 'appServer.log');
         } 
     }

But when save customer. log file is not create. I want to override _beforeSave Function.

Please anyone suggest me how to fix this.

هل كانت مفيدة؟

المحلول

You have to add models node and follow below code

<?xml version="1.0"?>
<config>
    <modules>
       <Abc_CustomizeCustomers>
       <version>0.1.0</version>
       </Abc_CustomizeCustomers>
    </modules>
    <global>
       <models>
          <customer_resource>
            <rewrite> 
              <customer>Abc_CustomizeCustomers_Model_Resource_Customer</customer>
            </rewrite>
          </customer_resource>
       </models>
    </global>
</config>

And file will be extends Mage_Customer_Model_Resource_Customer

<?php
    class Abc_CustomizeCustomers_Model_Resource_Customer extends 
      Mage_Customer_Model_Resource_Customer
     {
         public function __construct()
         { echo "dsfsdfdsfsd"; exit;


         } 
     }

Second solution you can use event for that too customer_save_before

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top