最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Assign Magento 2 Product image type to multiple images - Stack Overflow

programmeradmin4浏览0评论

In magento 2 the image types seem to function as radio buttons, I however want to change one of the types (a custom one) to function as a checkbox, so basically allow multiple images to have this attribute. And then be able to filter them out of the image gallery. I have been looking for a solution and trying out multiple things, but I cant seem to get it done. In magento 2 I have created the type 'Certificate' and I want to be able to assign it to multiple images under a product.

    /**
     * @inheritdoc
     */
    public function apply(): self
    {
        $this->moduleDataSetup->getConnection()->startSetup();

        $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
        $eavSetup->addAttribute(
            Product::ENTITY,
            'certificate_image',
            [
                'type' => 'text',
                'label' => 'Certificate',
                'input' => 'media_image',
                'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image',
                'global' => ScopedAttributeInterface::SCOPE_STORE,
                'filterable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => false,
                'sort_order' => 100,
                'required' => false,
                'is_user_defined' => true,
            ]
        );


        $this->moduleDataSetup->getConnection()->endSetup();
        return $this;
    }
发布评论

评论列表(0)

  1. 暂无评论