Shopware example



        $insertSql = 'INSERT INTO s_emarketing_lastarticles (`articleID`, `sessionID`, `time`, `userID`, `shopID`) VALUES (:articleId, :sessionId, NOW(), :userId, :shopId) ON DUPLICATE KEY UPDATE `time` = NOW(), `userID` = VALUES(userID)';

        $this->container->get(\Doctrine\DBAL\Connection::class)->executeUpdate(
            $insertSql,
            [
                'articleId' => $productId,
                'sessionId' => $sessionId,
                'userId' => (int) Shopware()->Session()->get('sUserId'),
                'shopId' => $this->container->get('shop')->getId(),
            ]
        );
    }
}
$this->controllers = $controllers;
        $this->container = $container;
        parent::__construct();
    }

    /** * @return \Shopware\Components\DispatchFormatHelper */
    public function getDispatchFormatHelper()
    {
        if ($this->dispatchFormatHelper === null) {
            $this->dispatchFormatHelper = Shopware()->Container()->get('shopware.components.dispatch_format_helper');
        }

        return $this->dispatchFormatHelper;
    }

    /** * Returns the formatted controller name. Removes all '_' . * * @param string $unFormatted * * @return string */
$this->setCountry($address->getCountry());
        $this->setPhone((string) $address->getPhone());
        $this->setVatId((string) $address->getVatId());
        $this->setTitle($address->getTitle());

        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            $this->setState(null);
        }

        $attributeData = Shopware()->Models()->toArray($address->getAttribute());
        $this->setAttribute($attributeData);
    }

    /** * @return string|null */
    public function getTitle()
    {
        return $this->title;
    }

    

    public function indexAction()
    {
        if ($this->Request()->getParam('isXHR')) {
            $this->View()->loadTemplate('frontend/custom/ajax.tpl');
        }

        $shopId = $this->container->get(ContextServiceInterface::class)->getShopContext()->getShop()->getId();

        $staticPage = Shopware()->Modules()->Cms()->sGetStaticPage($this->Request()->get('sCustom')$shopId);

        if (!\is_array($staticPage)) {
            throw new ResourceNotFoundException('Custom page not found', $this->Request());
        }

        if (!empty($staticPage['link'])) {
            $link = Shopware()->Modules()->Core()->sRewriteLink($staticPage['link']$staticPage['description']);

            $this->redirect($link['code' => Response::HTTP_MOVED_PERMANENTLY]);

            return;
        }
$this->set('sessionId', $this->getId());
    }

    public function start()
    {
        // Generally `start()` is called by Shopware's session factories         // - Shopware_Plugins_Backend_Auth_Bootstrap::onInitResourceBackendSession()         // - Shopware\Components\DependencyInjection\Bridge\Session::createSession()         // In case the session is started somewhere else we need to ensure no other session is active. The same logic as         // in Shopware's factories is used here.         // This behaviour is analogue to Zend: https://github.com/shopware5/shopware/blob/cbc212ca4642878cac62193d3a2f41e08f4849a2/engine/Library/Zend/Session.php#L413         $container = Shopware()->Container();
        self::ensureFrontendSessionClosed($container);
        self::ensureBackendSessionClosed($container);

        return parent::start();
    }

    public static function ensureFrontendSessionClosed($container)
    {
        self::ensureSessionClosed($container, 'session');
    }

    
/** * @var string */
    protected $blogBaseUrl;

    /** * @return void */
    public function init()
    {
        $this->blogBaseUrl = Shopware()->Config()->get('baseFile');
    }

    public function preDispatch()
    {
        $this->View()->setScope(Enlight_Template_Manager::SCOPE_PARENT);
    }

    /** * Helper Method to get access to the blog repository. * * @return BlogRepository */

function smarty_modifier_tax($value$locale = null)
{
    if (!is_numeric($value)) {
        throw new InvalidArgumentException(sprintf('Input %s must be numeric.', (string) $value));
    }

    $format['precision'] = 2;
    $format['locale'] = $locale;
    if (!$locale) {
        $format['locale'] = Shopware()->Container()->get('locale');
    }

    // check if value is integer     if ((int) $value == $value) {
        $format['precision'] = 0;
    }

    return Zend_Locale_Format::toNumber($value$format);
}

    if (!empty($format) && \is_string($format)) {
        if (\defined('Zend_Date::' . strtoupper($format))) {
            $format = \constant('Zend_Date::' . strtoupper($format));
        }
    }
    if (!empty($type) && \is_string($type)) {
        $type = strtolower($type);
    }

    /** @var Zend_Locale $locale */
    $locale = Shopware()->Container()->get('locale');
    if (\is_string($value)) {
        $value = strtotime($value);
    } elseif ($value instanceof DateTime) {
        /** @var \DateTime $value */
        $value = $value->getTimestamp();
    }

    $date = new Zend_Date($value, Zend_Date::TIMESTAMP, $locale);

    $value = $date->toString($format$type);

    
'link' => 'http://www.shopware.de/',
        ];
    }

    /** * Helper function to get access on the sRewriteTable component. * * @return sRewriteTable */
    public function RewriteTable()
    {
        return Shopware()->Modules()->RewriteTable();
    }

    /** * Helper function to get access on the SeoIndex component. * * @return Shopware_Components_SeoIndex */
    public function SeoIndex()
    {
        return Shopware()->Container()->get('seoindex');
    }

    

abstract class Enlight_Components_Test_TestCase extends TestCase
{
    /** * Sets up the fixture, for example, open a network connection. */
    protected function setUp(): void
    {
        parent::setUp();

        // Clear entitymanager to prevent weird 'model shop not persisted' errors.         Shopware()->Models()->clear();
    }

    /** * Performs operation returned by getSetUpOperation(). */
    protected function tearDown(): void
    {
        set_time_limit(0);
        ini_restore('memory_limit');
    }

    
break;
        }

        $this->View()->assign(['success' => true]);
    }

    /** * Gets a list of id-name of all existing shops */
    public function getShopsAction()
    {
        $shops = Shopware()->Db()->fetchAll('SELECT id, name FROM s_core_shops');
        $this->View()->assign([
            'success' => true,
            'data' => $shops,
        ]);
    }

    public function getConfigAction()
    {
        Shopware()->Container()->get(Zend_Cache_Core::class)->remove(CacheManager::ITEM_TAG_CONFIG);
        $this->View()->assign([
            'success' => true,
            
            $this->Request()->setParam('limit', null);
        }
        parent::preDispatch();
    }

    /** * @return void */
    public function init()
    {
        parent::init();
        $currency = Shopware()->Db()->fetchRow(
            'SELECT templatechar as sign, (symbol_position = 16) currencyAtEnd FROM s_core_currencies WHERE standard = 1'
        );

        $this->View()->assign('analyticsCurrency', $currency);
    }

    /** * {@inheritdoc} */
    

    }

    /** * @throws Enlight_Controller_Exception * * @return Shopware_Components_Auth|null */
    public function checkAuth()
    {
        /** @var Shopware_Components_Auth $auth */
        $auth = Shopware()->Container()->get('auth');
        if ($auth->hasIdentity()) {
            $auth->refresh();
        }

        $this->initLocale();

        if ($auth->hasIdentity()) {
            $identity = $auth->getIdentity();

            $this->acl = Shopware()->Acl();
            $this->aclRole = $identity->role;

            
return 1;
        }

        $pluginPath = $pluginManager->getPluginPath($pluginName);

        $message = null;
        if ($plugin->getSource() === 'Default') {
            $message = "'Default' Plugins may not be deleted.";
        } elseif (!$this->deletePath($pluginPath)) {
            $message = 'Plugin path "' . $pluginPath . '" could not be deleted.';
        } else {
            Shopware()->Models()->remove($plugin);
            Shopware()->Models()->flush();
        }

        if ($message) {
            $output->writeln($message);

            return 1;
        }
        $output->writeln(sprintf('Plugin %s has been deleted successfully.', $pluginName));

        return 0;
    }


    /** * Duplicate document properties */
    public function duplicatePropertiesAction()
    {
        $this->View()->setTemplate();
        $id = $this->Request()->id;

        // Update statement         $getDocumentTypes = Shopware()->Db()->fetchAll(
            'SELECT DISTINCT id FROM s_core_documents WHERE id != ?',
            [$id]
        );
        foreach ($getDocumentTypes as $targetID) {
            Shopware()->Db()->query(
                'DELETE FROM s_core_documents_box WHERE documentID = ?',
                [$targetID['id']]
            );
            $sqlDuplicate = 'INSERT IGNORE INTO s_core_documents_box SELECT NULL AS id, ? AS documentID , name, style, value FROM s_core_documents_box WHERE `documentID` = ?; ';
Home | Imprint | This part of the site doesn't use cookies.