title: Change attribute data for a store - Magento 2
body: <p>I have created a custom attribute for customer using InstallData in magento 2. </p>
  
  <p>However I wanted to change the <code>is_required</code> option of the attribute store wise.</p>
  
  <p><code>updateAttribute</code> can do the same however I don't know how to use it store wise.</p>
  
  <pre><code>        $customerSetup-&gt;updateAttribute('customer', 'tax_exempted', 'is_required', true);
  </code></pre>
  
  <p>Code Snippet to create attribute.</p>
  
  <pre><code>namespace xyz\abc\Setup;
  
  use Magento\Customer\Model\Customer;
  use Magento\Framework\Setup\ModuleContextInterface;
  use Magento\Framework\Setup\ModuleDataSetupInterface;
  
  /**
   * Install attributes
   */
  class InstallData implements \Magento\Framework\Setup\InstallDataInterface
  {
  
  /**
   * @var \Magento\Customer\Setup\CustomerSetupFactory
   */
  protected $customerSetupFactory;
  
  /**
   * @var \Magento\Eav\Api\AttributeRepositoryInterface
   */
  protected $attributeRepository;
  
  /**
   * Init
   *
   * @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
   * @param \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository
   */
  public function __construct(
      \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory,
      \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository
  ) {
      $this-&gt;customerSetupFactory = $customerSetupFactory;
      $this-&gt;attributeRepository = $attributeRepository;
  }
  
  /**
   * DB setup code
   *
   * @param \Magento\Framework\Setup\SchemaSetupInterface $setup
   * @param \Magento\Framework\Setup\ModuleContextInterface $context
   * @return void
   */
  public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
      /** @var \Magento\Customer\Setup\CustomerSetup $customerSetup */
      $customerSetup = $this-&gt;customerSetupFactory-&gt;create(['setup' =&gt; $setup]);
  
      $setup-&gt;startSetup();
  
      if ($customerSetup-&gt;getAttributeId('customer', 'tax_exempted') === false) {
          $custAttr = $customerSetup-&gt;addAttribute(
                  Customer::ENTITY,
                  'tax_exempted',
                  [
                      'label'            =&gt; 'Is Tax Exempted',
                      'type'             =&gt; 'int',
                      'input'            =&gt; 'boolean',
                      'default'          =&gt; '0',
                      'position'         =&gt; 71,
                      'visible'          =&gt; true,
                      'required'         =&gt; false,
                      'system'           =&gt; false,
                      'user_defined'     =&gt; true,
                      'visible_on_front' =&gt; false,
                  ]
              );
  
          $taxExemptedAttr = $customerSetup-&gt;getEavConfig()-&gt;getAttribute(
              Customer::ENTITY,
              'tax_exempted'
          );
  
          $this-&gt;attributeRepository-&gt;save($taxExemptedAttr);
  
      }
  
      $setup-&gt;endSetup();
  }
  }
  </code></pre>