I would like to change returned value by this core function:


public function isUsingStaticUrlsAllowed()
        $checkResult = new \StdClass();
        $checkResult->isAllowed = false;
            ['result' => $checkResult, 'store_id' => $this->_storeId]
        return $checkResult->isAllowed;

I created my own observer:

public function execute(\Magento\Framework\Event\Observer $observer)

        $result  = $observer->getEvent()->getResult();
        $result->isAllowed = true;

But it does not work and does not make sense (?). Can I change this value via observer or i need to use plugin ?


Because an observer for this event already exists that is setting the same property (Magento\Catalog\Observer\CatalogCheckIsUsingStaticUrlsAllowedObserver) you should instead use a plug-in because there's no reliable way to tell Magento to execute your observer after the other one executes.

| improve this answer | |
  • 1
    By the way, you can control this setting in the backend - Store > Configuration > Content Management > Use Static URLs for Media Content in WYSIWYG for Catalog. So there's no reason to create this plugin unless you want to override the config setting. – Aaron Allen Jan 1 '17 at 23:57

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.