Clear page cache on product import
This commit is contained in:
@@ -27,18 +27,42 @@ namespace EP\EpProducts\Command;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Service\ImportService;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
|
||||
use TYPO3\CMS\Extbase\Service\CacheService;
|
||||
|
||||
class ProductCommandController extends CommandController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \EP\EpProducts\Service\ImportService
|
||||
* @inject
|
||||
*/
|
||||
protected $importService;
|
||||
|
||||
/**
|
||||
* @var CacheService
|
||||
*/
|
||||
protected $cacheService;
|
||||
|
||||
/**
|
||||
* @var ConfigurationManagerInterface
|
||||
*/
|
||||
protected $configurationManager;
|
||||
|
||||
/**
|
||||
* @param ImportService $importService
|
||||
* @param CacheService $cacheService
|
||||
* @param ConfigurationManagerInterface $configurationManager
|
||||
*/
|
||||
public function __construct(ImportService $importService, CacheService $cacheService, ConfigurationManagerInterface $configurationManager)
|
||||
{
|
||||
$this->importService = $importService;
|
||||
$this->cacheService = $cacheService;
|
||||
$this->configurationManager = $configurationManager;
|
||||
}
|
||||
|
||||
public function importCommand()
|
||||
{
|
||||
$path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport');
|
||||
@@ -47,7 +71,22 @@ class ProductCommandController extends CommandController
|
||||
} else {
|
||||
$count = $this->importService->import($path);
|
||||
$this->outputLine('%d rows imported.', [ $count ]);
|
||||
$settings = $this->getSettings();
|
||||
$resellerPageUid = $settings['resellerExportPageUid'];
|
||||
$this->cacheService->clearPageCache($resellerPageUid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getSettings()
|
||||
{
|
||||
$settings = $this
|
||||
->configurationManager
|
||||
->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
|
||||
|
||||
return $settings['plugin.']['tx_epproducts.']['settings.'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ class BackendController extends ActionController
|
||||
} else {
|
||||
$dateCount = $this->importService->import($path);
|
||||
$this->addFlashMessage($dateCount . ' Termine importiert', 'Import abgechlossen', AbstractMessage::OK);
|
||||
$resellerPageUid = $this->settings['resellerExportPageUid'];
|
||||
$this->cacheService->clearPageCache($resellerPageUid);
|
||||
}
|
||||
$this->redirect('index');
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ class ResellerController extends ActionController
|
||||
/**
|
||||
* @param Reseller $reseller
|
||||
* @param Product $product
|
||||
* @return bool
|
||||
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
|
||||
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
|
||||
*/
|
||||
@@ -84,13 +85,14 @@ class ResellerController extends ActionController
|
||||
}
|
||||
|
||||
$data = $this->resellerService->preprocessSingle($product);
|
||||
var_dump($data);exit;
|
||||
//TODO: Implement Excel sheet generation
|
||||
var_dump($data);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Reseller $reseller
|
||||
* @return mixed
|
||||
* @return bool
|
||||
*/
|
||||
public function xmlAction(Reseller $reseller)
|
||||
{
|
||||
@@ -103,10 +105,9 @@ class ResellerController extends ActionController
|
||||
|
||||
$serializer = new Serializer($normalizers, $encoders);
|
||||
|
||||
header('Content-type: text/xml;charset=utf-8');
|
||||
|
||||
echo $serializer->serialize($data, 'xml', [ 'xml_encoding' => 'utf-8', 'xml_format_output' => true ]);
|
||||
exit;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user