Export example

if (!is_dir($this->cacheDir)) {
            if (@mkdir($this->cacheDir, 0777, true) === false) {
                throw new RuntimeException(sprintf("Unable to create directory '%s'\n", $this->cacheDir));
            }
        } elseif (!is_writable($this->cacheDir)) {
            throw new RuntimeException(sprintf("Unable to write in directory '%s'\n", $this->cacheDir));
        }

        $feedId = (int) $input->getOption('feed-id');

        $export = $this->container->get('modules')->Export();

        $export->sSYSTEM = $this->container->get('modules')->System();

        $this->sSmarty = $this->container->get(Enlight_Template_Manager::class);

        // Prevent notices to clutter generated files         $this->registerErrorHandler($output);

        $productFeedRepository = $this->container->get(ModelManager::class)->getRepository(ProductFeed::class);
        if (empty($feedId)) {
            $activeFeeds = $productFeedRepository->getActiveListQuery()->getResult();

            

        /** @var string $cacheDir */
        $cacheDir = Shopware()->Container()->getParameter('shopware.product_export.cache_dir');
        if (!is_dir($cacheDir)) {
            if (@mkdir($cacheDir, 0777, true) === false) {
                throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", 'Productexport', $cacheDir));
            }
        } elseif (!is_writable($cacheDir)) {
            throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", 'Productexport', $cacheDir));
        }

        $export = Shopware()->Modules()->Export();
        $export->sSYSTEM = Shopware()->System();
        $sSmarty = Shopware()->Template();

        $productFeedRepository = Shopware()->Models()->getRepository(ProductFeed::class);
        $activeFeeds = $productFeedRepository->getActiveListQuery()->getResult();
        foreach ($activeFeeds as $feedModel) {
            $fileName = $feedModel->getHash() . '_' . $feedModel->getFileName();
            $filePath = $cacheDir . $fileName;

            if ($feedModel->getInterval() === 0) {
                continue;
            }
/** * Init controller method * * Disables the authorization-checking and template renderer. */
    public function init()
    {
        Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        Shopware()->Front()->Plugins()->ViewRenderer()->setNoRender();
        $this->Front()->setParam('disableOutputBuffering', true);
        $this->export = Shopware()->Modules()->Export();
    }

    /** * Index action method * * Creates the export product. */
    public function indexAction()
    {
        $this->prepareExport();
        $this->sendHeaders();

        
Home | Imprint | This part of the site doesn't use cookies.