I have created a preference to override the functionality of customer save. But the I need to use the core customer save functionality for 1 website and my preference functionality for another website. So how can I implement this?

Please help.

Thanks in advance.


You likely do not need a preference here and instead you very likely can achieve your changes via a plugin on the save method.

In the plugin code itself you can add a check for the website to either execute the changes or keep it as is.

|improve this answer|||||

There are not any native functionality to the differentiate preference for multiple websites or stores.

You can make a condition for the current store or website by Magento\Store\Model\StoreManagerInterface in the overridden method.


public function myFunction($item)
    if($this->_storeManager->getStore()->getWebsiteId() == '1') {
        //Do your customisation 
    } else {
        //Return main function
        return parent::myFunction($item);
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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