magento2
magento2 copied to clipboard
Multi website - customer create form - Attribute Cache not taking account the current website/store
Preconditions
- Magento CE 2.1.9
- Multi website / and multi stores (B2B (with languages : FR, EN) + B2C (with languages FR, EN, JP)
- Php 5.6
Steps to reproduce
- For the B2b website I want to display Tax / Vat field. And I don't want to display DOB field
- For the B2C website I don't want to display Tax / Vat field, but I do want to display DOB field (optional).
- 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
- I flush all cache
- I go to B2B website on customer/account/create => generate form and display Tax / Vat field as optional and hide Dob field
- I go to B2C website on customer/account/create => generate form and display Dob field as optional but hide Tax / Vat field.
Actual result
-
I flush all cache
-
I go to B2B website on customer/account/create => generate form and it display Tax / Vat field as optional and hide Dob field => OK!
-
I go to B2C website on customer/account/create => generate form and it display the same form as B2B website => NOK!
-
I flush cache
-
I go to B2C website on customer/account/create => generate form and it display Dob field as optional but hide Tax / Vat field => OK!
-
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.