Magento – bulk edit for custom attribute is not working

magento2

While editing custom attribute of product if i edit one by one then custom attribute is updating but when i am using mass edit custom attribute will not update and will use default value and update all products.

How can i fix this bulk attribute thing to be able to save it?

I have tried updating default value from database eav_attribute table but didn't work either. setup/installData.php script is this

    <?php
namespace Magecomp\Customstock\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->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_stocktext',
            [
                'type' => 'varchar',
                'label' => 'Stock Text',
                'backend' => '',
                'input' => 'text',
                'source' => '',
                'required' => false,
                'sort_order' => 2,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Enter custom availability text here if wanted.'
            ]
        );
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_stockmessage',
            [
                'type' => 'text',
                'label' => 'Stock Message',
                'backend' => '',
                'input' => 'select',
                'source' => '',
                'required' => false,
                'sort_order' => 3,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Select a stock message here if wanted. If custom availability text is entered above, it will override this message. Add more messages by going to <b>Catalog->Attributes->Manage Attributes</b> and clicking on the \'mc_stockmessage\' attribute.'
            ]
        );
         $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_ships_in',
            [
                'type' => 'varchar',
                'label' => 'Order Processing Time',
                'backend' => '',
                'input' => 'text',
                'frontend_class' => 'validate-digits',
                'source' => '',
                'required' => false,
                'sort_order' => 4,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Days to process order. Leave blank for default. To show in stock status, use variable <b>%days%</b>.'
            ]
        );
         $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_expecdate',
            [
                'type' => 'datetime',
                'label' => 'Expected In-Stock Date',
                'frontend' => 'Magento\Eav\Model\Entity\Attribute\Frontend\Datetime',
                'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime',
                'input' => 'date',
                'source' => '',
                'required' => false,
                'sort_order' => 5,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Date the product is expected to be back in-stock. To show in stock status, use variable <b>%expec%</b>.'
            ]
        );
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_preorderdate',
            [
                'type' => 'datetime',
                'label' => 'On Pre-Order Until',
                'frontend' => 'Magento\Eav\Model\Entity\Attribute\Frontend\Datetime',
                'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\Datetime',
                'input' => 'date',
                'source' => '',
                'required' => false,
                'sort_order' => 6,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Date the product will no longer show as a pre-order. To show in pre-order text, use variable <b>%pod%</b>.'
            ]
        );
         $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_preordertext',
            [
                'type' => 'varchar',
                'label' => 'Pre-Order Text',
                'backend' => '',
                'input' => 'text',
                'source' => '',
                'required' => false,
                'sort_order' => 7,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Enter pre-order text here if wanted, otherwise pre-order date will be shown.'
            ]
        );
        $eavSetup->addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'mc_hideshipdate',
            [
                'type' => 'text',
                'label' => 'Hide Ship Date?',
                'backend' => '',
                'input' => 'select',
                'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                'default' => '0',
                'required' => false,
                'sort_order' => 8,
                'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
                'group' => 'Custom Stock Status',
                'used_in_product_listing' => true,
                'visible_on_front' => true,
                'note' => 'Do you want to hide the ship date info for this product?'
            ]
        );
        $setup->endSetup();

    }
}

Best Answer

  • I would look for an error in error logs and if nothing appear in Magento logs or apache log (or nginx if you use nginx), then look at your browser console.
  • Once you have identified the error, then disable modules if the error comes from a custom module. This way, you may first have your bulk update working and hopefully pinpoint the issue..
Related Topic