addMediaPaths example

/** * @param ShopContext|ShopContextInterface $context */
    public function prepare(PrepareDataCollection $collection, Element $element, ShopContextInterface $context)
    {
        $imageType = $element->getConfig()->get('image_type');
        $key = ComponentHandlerInterface::CRITERIA_KEY . $element->getId();

        switch ($imageType) {
            case self::TYPE_IMAGE:
                if (!empty($element->getConfig()->get('image'))) {
                    $collection->addMediaPaths([$element->getConfig()->get('image')]);
                }

                break;

            case self::TYPE_ARTICLE_OR_BLOG:
                $isBlog = (bool) $element->getConfig()->get('blog_category');
                $categoryId = (int) $element->getConfig()->get('category_selection');

                if ($isBlog) {
                    break;
                }

                
public function supports(Element $element)
    {
        return $element->getComponent()->getType() === self::COMPONENT_NAME
            || $element->getComponent()->getConvertFunction() === self::LEGACY_CONVERT_FUNCTION;
    }

    /** * {@inheritdoc} */
    public function prepare(PrepareDataCollection $collection, Element $element, ShopContextInterface $context)
    {
        $collection->addMediaPaths([$element->getConfig()->get('file')]);

        $this->generateLink($element$context);
        $this->addMappings($collection$element$context);
    }

    /** * {@inheritdoc} */
    public function handle(ResolvedDataCollection $collection, Element $element, ShopContextInterface $context)
    {
        $bannerPath = $element->getConfig()->get('file');
        
Home | Imprint | This part of the site doesn't use cookies.