2

I have added an product yes_no attribute named save_print from admin. It has successfully added and showing in product(admin). When I change the value. Value is not reflecting in back-end.

I have debugged into this and found that attribute value doesn't insert into database. I thought, It may be due to php post_max_size. So I have increased the value of post_max_size to 32M and upload_max_size to 32M but it didn't work. I don't why it is happening. Please help to solve this.

Here is the attribute database enter image description here Any help would be appreciated.

Thanks,

1

You need create column with name save_print in this table.

Setup/InstallData.php

<?php

namespace Vendor\Module\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,
          "save_print ",
          [
          'group' => "",
          'label' => "save_print ",
          'is_html_allowed_on_front' => true,
          'default' => '1',
          'note' => '',
          'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
          'visible' => true,
          'required' => false,
          'user_defined' => false,
          'searchable' => false,
          'filterable' => false,
          'comparable' => false,
          'visible_on_front' => true,
          'visible_in_advanced_search' => false,
          'unique' => false,
          "frontend_class" => "",
          "used_in_product_listing" => true,
          "input" => "select",
          "type" => "int",
          "source" => "Magento\Config\Model\Config\Source\Yesno",
          'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend'
          ]
      );
    }
}

All done, please run the upgrade script php bin/magento setup:upgrade to install the module and the product attribute sample_attribute will be created. After run upgrade complete, please run php

bin/magento setup:static-content:deploy.
  • Thanks for your reply. It works but it shows drop-down instead toggle yes no option. I need toggle. – zed Blackbeard Jul 1 '18 at 16:55
0

Continuously 4 hours digging into code, Finally I got the solution. In my case I found there are two table which has same attribute (save_print) record.

Tables are catalog_product_entity_int and catalog_product_entity_varchar

Both had a record of save_print attribute. As this product have int type backend_type and value of this attribute update in catalog_product_entity_int but fetching the value from catalog_product_entity_varchar So I have delete the record of catalog_product_entity_varchar and it works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.