Articles example


    public function sGetArticleImageLinks($articleId$orderNumber$imageSize = null, $separator = '|')
    {
        $imageSize = ($imageSize === null) ? 'original' : $imageSize;
        $returnData = [];
        if (empty($articleId) || empty($orderNumber)) {
            return '';
        }
        $imageData = Shopware()->Modules()->Articles()->sGetArticlePictures($articleId, false, null, $orderNumber);
        $cover = Shopware()->Modules()->Articles()->sGetArticlePictures($articleId, true, null, $orderNumber);
        $returnData[] = $cover['src'][$imageSize];
        foreach ($imageData as $image) {
            $returnData[] = $image['src'][$imageSize];
        }

        return implode($separator$returnData);
    }

    /** * Returns an array with the product property data. * Needs to be parsed over the feed smarty template * * @param int $articleId * @param int $filterGroupId * * @return array */

            [$userId]
        );

        foreach ($getOrders as $orderKey => $orderValue) {
            if (($this->config->get('sARTICLESOUTPUTNETTO') && !$this->sSYSTEM->sUSERGROUPDATA['tax'])
                || (!$this->sSYSTEM->sUSERGROUPDATA['tax'] && $this->sSYSTEM->sUSERGROUPDATA['id'])
            ) {
                $getOrders[$orderKey]['invoice_amount'] = $this->moduleManager->Articles()
                    ->sFormatPrice($orderValue['invoice_amount_net']);
                $getOrders[$orderKey]['invoice_shipping'] = $this->moduleManager->Articles()
                    ->sFormatPrice($orderValue['invoice_shipping_net']);
            } else {
                $getOrders[$orderKey]['invoice_amount'] = $this->moduleManager->Articles()
                    ->sFormatPrice($orderValue['invoice_amount']);
                $getOrders[$orderKey]['invoice_shipping'] = $this->moduleManager->Articles()
                    ->sFormatPrice($orderValue['invoice_shipping']);
            }

            /** @var array $getOrderDetails */
            
public function preDispatch()
    {
        $this->Response()->setHeader('x-robots-tag', 'noindex');
    }

    /** * @return void */
    public function init()
    {
        $this->config = Shopware()->Config();
        $this->articleModule = Shopware()->Modules()->Articles();
        $this->marketingModule = Shopware()->Modules()->Marketing();
    }

    /** * Show similar viewed articles */
    public function viewedAction()
    {
        $productId = (int) $this->Request()->getParam('articleId');
        $maxPages = (int) $this->config->get('similarViewedMaxPages', 10);
        $perPage = (int) $this->config->get('similarViewedPerPage', 4);

        

    private function formatBasketRow($basketRow)
    {
        $basketRow['articlename'] = str_replace('<br />', "\n", $basketRow['articlename']);
        $basketRow['articlename'] = html_entity_decode($basketRow['articlename']);
        $basketRow['articlename'] = strip_tags($basketRow['articlename']);
        $basketRow['articlename'] = Shopware()->Modules()->Articles()->sOptimizeText(
            $basketRow['articlename']
        );

        if (empty($basketRow['price'])) {
            $basketRow['price'] = '0,00';
        }
        if (empty($basketRow['esdarticle'])) {
            $basketRow['esdarticle'] = '0';
        }
        if (empty($basketRow['modus'])) {
            $basketRow['modus'] = '0';
        }

    /** * Pre dispatch method */
    public function preDispatch()
    {
        $this->Response()->setHeader('x-robots-tag', 'noindex');
    }

    public function indexAction()
    {
        $this->View()->assign('sComparisons', Shopware()->Modules()->Articles()->sGetComparisons());
    }
}
if (empty($this->Request()->sDetails)) {
            $id = $this->Request()->sArticle;
        } else {
            $id = $this->Request()->sDetails;
        }

        if (empty($id)) {
            return $this->forward('index', 'index');
        }

        // Get Product-Information         $product = Shopware()->Modules()->Articles()->sGetPromotionById('fix', 0, (int) $id);
        if (empty($product['articleName'])) {
            return $this->forward('index', 'index');
        }

        if ($this->Request()->getPost('sMailTo')) {
            $variables['sError'] = false;
            if (!$this->Request()->getPost('sName')) {
                $variables['sError'] = true;
            }
            if (!$this->Request()->getPost('sMail')) {
                $variables['sError'] = true;
            }
$this->redirect(['action' => 'index']);
    }

    /** * @return void */
    public function addAction()
    {
        $orderNumber = (string) $this->Request()->getParam('ordernumber');

        if ($this->addNote($orderNumber)) {
            $this->View()->assign('sArticleName', Shopware()->Modules()->Articles()->sGetArticleNameByOrderNumber($orderNumber));
        }

        $this->redirect(['action' => 'index']);
    }

    /** * @return void */
    public function ajaxAddAction()
    {
        $this->Request()->setHeader('Content-Type', 'application/json');
        
$addPremium,
                $sBasketAmount,
            ]
        );

        if (!$premium) {
            return false;
        }

        // Load translations for product or variant         if ($premium['main_detail_id'] !== $premium['variantID']) {
            $premium = $this->moduleManager->Articles()->sGetTranslation(
                $premium,
                $premium['variantID'],
                'variant'
            );
        } else {
            $premium = $this->moduleManager->Articles()->sGetTranslation(
                $premium,
                $premium['articleID'],
                'article'
            );
        }

        

    private function mergeAmount(array $item1, array $item2, string $property)
    {
        $hasComma = str_contains($item1[$property] ?? '', ',');
        $amount = (float) str_replace(',', '.', $item1[$property] ?? '') + (float) str_replace(',', '.', $item2[$property] ?? '');

        if ($hasComma) {
            $amount = $this->modules->Articles()->sFormatPrice($amount);
        }

        return $amount;
    }
}
 {
        $container = Shopware()->Container();

        $category = $container->get('shop')->getCategory();
        $this->categoryId = (int) ($category ? $category->getId() : 0);
        $this->contextService = $contextService ?? $container->get(ContextServiceInterface::class);
        $this->customerGroupId = (int) $this->contextService->getShopContext()->getCurrentCustomerGroup()->getId();

        $this->additionalTextService = $additionalTextService ?? $container->get(AdditionalTextServiceInterface::class);

        $this->config = $config ?? $container->get('config');
        $this->productModule = $productModule ?? $container->get('modules')->Articles();
        $this->basketModule = $basketModule ?? $container->get('modules')->Basket();
        $this->front = $front ?: $container->get('front');
        $this->connection = $connection ?: $container->get(Connection::class);
        $this->modelManager = $modelManager ?: $container->get(ModelManager::class);
        $this->mediaService = $mediaService ?: $container->get(MediaServiceInterface::class);
        $this->storefrontMediaService = $storefrontMediaService ?: $container->get(StorefrontMediaServiceInterface::class);
        $this->legacyStructConverter = $legacyStructConverter ?: $container->get(LegacyStructConverter::class);
        $this->eventManager = $eventManager ?: $container->get(ContainerAwareEventManager::class);
    }

    /** * @param int $articleId * @param int $limit * * @return array<array<string, mixed>> */
$this->view->assign('sortings', $sortings);
        }

        $criteria = $this->storeFrontCriteriaFactory
            ->createListingCriteria($this->Request()$context);

        if ($condition = $criteria->getCondition('manufacturer')) {
            $criteria->removeCondition('manufacturer');
            $criteria->addBaseCondition($condition);
        }

        $categoryProducts = Shopware()->Modules()->Articles()->sGetArticlesByCategory(
            $context->getShop()->getCategory()->getId(),
            $criteria
        );
        if (!\is_array($categoryProducts)) {
            $categoryProducts = ['facets' => []];
        }

        $manufacturer = $this->manufacturerService->get(
            $manufacturerId,
            $context
        );

        
class Shopware_Controllers_Frontend_Compare extends Enlight_Controller_Action
{
    /** * @var sArticles */
    protected $articles;

    public function preDispatch()
    {
        $this->View()->setScope(Enlight_Template_Manager::SCOPE_PARENT);
        $this->articles = Shopware()->Modules()->Articles();
    }

    public function indexAction()
    {
        $this->View()->assign('sComparisons', $this->articles->sGetComparisons());
    }

    public function addArticleAction()
    {
        if (($productId = $this->Request()->getParam('articleID')) !== null) {
            $this->View()->assign('sCompareAddResult', $this->articles->sAddComparison($productId));
        }


        $number = $this->Request()->getParam('number');
        $selection = $this->Request()->getParam('group', []);

        $categoryId = (int) $this->Request()->get('sCategory');
        if (!$this->isValidCategory($categoryId)) {
            $categoryId = 0;
        }

        try {
            $product = $this->container->get('modules')->Articles()->sGetArticleById(
                $id,
                $categoryId,
                $number,
                $selection
            );
        } catch (Exception $e) {
            $product = null;
        }

        if (empty($product) || empty($product['articleName'])) {
            $this->forward('error');

            

    public function addArticleAction()
    {
        $this->validatePostMethod();

        $orderNumber = trim($this->Request()->getParam('sAdd'));
        $quantity = (int) $this->Request()->getParam('sQuantity');
        $productId = Shopware()->Modules()->Articles()->sGetArticleIdByOrderNumber($orderNumber);
        $instockInfo = $this->getInstockInfo($orderNumber$quantity);

        $this->View()->assign('sBasketInfo', $instockInfo);

        if ($instockInfo !== null) {
            $this->session->offsetSet('sErrorMessages', $instockInfo);
        }

        if (!empty($productId)) {
            $insertId = $this->basket->sAddArticle($orderNumber$quantity);
            $this->View()->assign('sArticleName', Shopware()->Modules()->Articles()->sGetArticleNameByOrderNumber($orderNumber));
            
$this->checkFields();
        }

        $orderNumber = $this->Request()->getParam('sOrdernumber');

        if (empty($this->Request()->Submit) || \count($this->_errors)) {
            foreach ($this->_elements as $id => $element) {
                if ($element['name'] === 'sordernumber') {
                    try {
                        $this->get(OrderNumberValidatorInterface::class)->validate($orderNumber);

                        $product = Shopware()->Modules()->Articles()->sGetArticleNameByOrderNumber($orderNumber);

                        $element['value'] = sprintf('%s (%s)', $product$this->get('shopware.escaper')->escapeHtml($orderNumber));
                        $this->_elements[$id]['value'] = $element['value'];
                    } catch (InvalidOrderNumberException $exception) {
                        // Explicit empty catch                     } catch (TypeError $exception) {
                        // Explicit empty catch                     }
                }

                if ($element['name'] === 'inquiry' && !empty($this->Request()->sInquiry)) {
                    
Home | Imprint | This part of the site doesn't use cookies.