2

I am not able to make appear 2 of the 3 new attributes in magento_admin_site

here is the code in InstallaData.php

   <?php

    namespace Ht\Mymodule\Setup;

    use Magento\Eav\Setup\EavSetup;
    use Magento\Eav\Setup\EavSetupFactory;
    use Magento\Framework\Setup\InstallDataInterface;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\ModuleDataSetupInterface;

    class InstallData implements InstallDataInterface 
    {
        private $eavSetupFactory;

        public function __construct(EavSetupFactory $eavSetupFactory) 
        {
            $this->eavSetupFactory = $eavSetupFactory;
        }

        public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) 
        {
            $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);



            // $eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'custom_dropdown');
            $eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'custom_dropdown', [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'sort_order' => 100,
                'label' => 'Talle',
                'input' => 'select',
                'class' => '',
                'source' => 'Ht\Mymodule\Model\Source\Customdropdown',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'apply_to' => ''
            ]);
            $eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'composicion_dropdown', [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'sort_order' => 100,
                'label' => 'Descripción',
                'input' => 'select',
                'class' => '',
                'source' => 'Ht\Mymodule\Model\Source\Composicion',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'apply_to' => ''
            ]);
            $eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'edad_dropdown', [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'sort_order' => 100,
                'label' => 'Edad',
                'input' => 'select',
                'class' => '',
                'source' => 'Ht\Mymodule\Model\Source\Edad',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'apply_to' => ''
            ]);
            $eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'colores_dropdown', [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'sort_order' => 100,
                'label' => 'Colores',
                'input' => 'select',
                'class' => '',
                'source' => 'Ht\Mymodule\Model\Source\Colores',
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'apply_to' => ''
            ]);

        }
    }
**and foreach "dropdown" has it is own source example por "colores" we have**
    <?php

namespace Ht\Mymodule\Model\Source;

class Colores extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource 
{
    public function getAllOptions() {
        if ($this->_options === null) {
            $this->_options = [
                ['label' => __('3'), 'value' => 1],
                ['label' => __('4'), 'value' => 2],
                ['label' => __('49'), 'value' => 3],
                ['label' => __('59'), 'value' => 4],
                ['label' => __('69'), 'value' => 5],
                ['label' => __('73'), 'value' => 6],
                ['label' => __('77'), 'value' => 7],
                ['label' => __('91'), 'value' => 8],
                ['label' => __(' 018 syrup waffle delight'), 'value' => 9],
                ['label' => __(' 02 pinky promise'), 'value' => 10],
                ['label' => __(' 04 nature'), 'value' => 11],
                ['label' => __(' 08 smooth Sunday'), 'value' => 12],
                ['label' => __(' 10 flamboyant fla'), 'value' => 13],
                ['label' => __(' 103 siLLy shandy'), 'value' => 14],

                ['label' => __('Warm'), 'value' => 899]
            ];
        }
        return $this->_options;
    }
}

I hope someone can help me with this issue+

thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.