public function execute()
    {
        try {
            if ($this->config->getType() == Config::FASTLY && $this->config->isEnabled()) {
                // check if store exists
                $storeId = $this->getRequest()->getParam('stores', false);
                /** @var \Magento\Store\Model\Store $store */
                $store = $this->storeManager->getStore($storeId);
                if (!$store->getId()) {
                    throw new LocalizedException(__('Invalid store "'.$storeId.'" given.'));
                }

                $result = $this->purgeCache->sendPurgeRequest($store->getIdentities());

                if ($result) {
                    $this->getMessageManager()->addSuccessMessage(__('The Fastly CDN has been cleaned.'));
                } else {
                    $this->getMessageManager()->addErrorMessage(
                        __('The purge request was not processed successfully.')
                    );
                }
            }
        } catch (\Exception $e) {
            $this->getMessageManager()->addErrorMessage(
                __('An error occurred while clearing the Fastly CDN: ') . $e->getMessage()
            );
        }
        return $this->_redirect('*/cache/index');
    }
public function execute()
    {
        try {
            if ($this->config->getType() == Config::FASTLY && $this->config->isEnabled()) {
                
                $storeId = $this->getRequest()->getParam('stores', false);
                
                $store = $this->storeManager->getStore($storeId);
                if (!$store->getId()) {
                    throw new LocalizedException(__('Invalid store "'.$storeId.'" given.'));
                }

                $result = $this->purgeCache->sendPurgeRequest($store->getIdentities());

                if ($result) {
                    $this->getMessageManager()->addSuccessMessage(__('The Fastly CDN has been cleaned.'));
                } else {
                    $this->getMessageManager()->addErrorMessage(
                        __('The purge request was not processed successfully.')
                    );
                }
            }
        } catch (\Exception $e) {
            $this->getMessageManager()->addErrorMessage(
                __('An error occurred while clearing the Fastly CDN: ') . $e->getMessage()
            );
        }
        return $this->_redirect('*/cache/index');
    }
public function execute ( ) { try { if ( $ this -> config -> getType ( ) == Config :: FASTLY && $ this -> config -> isEnabled ( ) ) { // check if store exists $ storeId = $ this -> getRequest ( ) -> getParam ( 'stores' , false ) ; /** @var \Magento\Store\Model\Store $store */ $ store = $ this -> storeManager -> getStore ( $ storeId ) ; if ( ! $ store -> getId ( ) ) { throw new LocalizedException ( __ ( 'Invalid store "' . $ storeId . '" given.' ) ) ; } $ result = $ this -> purgeCache -> sendPurgeRequest ( $ store -> getIdentities ( ) ) ; if ( $ result ) { $ this -> getMessageManager ( ) -> addSuccessMessage ( __ ( 'The Fastly CDN has been cleaned.' ) ) ; } else { $ this -> getMessageManager ( ) -> addErrorMessage ( __ ( 'The purge request was not processed successfully.' ) ) ; } } } catch ( \ Exception $ e ) { $ this -> getMessageManager ( ) -> addErrorMessage ( __ ( 'An error occurred while clearing the Fastly CDN: ' ) . $ e -> getMessage ( ) ) ; } return $ this -> _redirect ( '*/cache/index' ) ; }
Purge by content type

@return \Magento\Framework\App\ResponseInterface
@throws \Exception
Purge by content type