magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Multi website - customer create form - Attribute Cache not taking account the current website/store

Open eInyzant opened this issue 7 years ago • 28 comments

Preconditions

  1. Magento CE 2.1.9
  2. Multi website / and multi stores (B2B (with languages : FR, EN) + B2C (with languages FR, EN, JP)
  3. Php 5.6

Steps to reproduce

  1. For the B2b website I want to display Tax / Vat field. And I don't want to display DOB field
  2. For the B2C website I don't want to display Tax / Vat field, but I do want to display DOB field (optional).
  3. So I set up these parameters in the backend Stores => Settings/Configuration => Customers / Customers configuration => Name and Address Options
Website Setting Value
B2B Show Date of birth No
B2B Show Tax/VAT Number Optional
B2C Show Date of birth Otptional
B2C Show Tax/VAT Number No

Expected result

  1. I flush all cache
  2. I go to B2B website on customer/account/create => generate form and display Tax / Vat field as optional and hide Dob field
  3. I go to B2C website on customer/account/create => generate form and display Dob field as optional but hide Tax / Vat field.

Actual result

  1. I flush all cache

  2. I go to B2B website on customer/account/create => generate form and it display Tax / Vat field as optional and hide Dob field => OK!

  3. I go to B2C website on customer/account/create => generate form and it display the same form as B2B website => NOK!

  4. I flush cache

  5. I go to B2C website on customer/account/create => generate form and it display Dob field as optional but hide Tax / Vat field => OK!

  6. I go to B2B website on customer/account/create => gernerate form and it display the same form as B2C website => NOK!

going deeper in the code I think the problem is related to the AttributeCache class :

Magento\Customer\Block\Widget\Taxvat Magento\Customer\Block\Widget\AbstractWidget::_getAttribute (:96) Magento\Customer\Model\Metadata::getAttributeMetadata (:62) Magento\Eav\Model\Entity\AttributeCache::saveAttributes (:108) => The cache Key does not take the website_id or store_id into account. So once it is cached on a website it will give the same result on the other websites.

eInyzant avatar Sep 21 '17 06:09 eInyzant