Magento - customer_save_after always fired twice

前端 未结 5 1734
旧时难觅i
旧时难觅i 2020-12-08 22:36

I am using the customer_save_after event in magento, and all is working fine apart from 1 annoying thing - it is always fired twice.

There are no other

5条回答
  •  借酒劲吻你
    2020-12-08 23:03

    I used a static var:

    private static $_handleCustomerFirstSearchCounter = 1;
    
    public function Savest($observer) {
        if (self::$_handleCustomerFirstSearchCounter > 1) {
            return $this;
        }
    
        $customerData = Mage::getSingleton('customer/session')->getCustomer();
        $model = Mage::getModel('customerst/customerst')
            ->setQueryText(Mage::app()->getRequest()->getParam('q'))
            ->setCustomerId($customerData->getId())
            ->setCustomerName($customerData->getName())
            ->save();
    
        self::$_handleCustomerFirstSearchCounter++;
    }
    

提交回复
热议问题