Closed
Description
Preconditions
- Product has a user defined attribute with scope : store-view. Created via:
`/** @var \Magento\Eav\Setup\EavSetup $eavSetup */`
`
$eavSetup->addAttribute(
'catalog_product',
'ced_profile_id',
[
'group' => $groupName,
'note' => 'Profile Id',
'input' => 'text',
'type' => 'varchar',
'label' => 'Profile Id ',
'backend' => '',
'visible' => 1,
'required' => 0,
'sort_order' => 1,
'user_defined' => 1,
'comparable' => 0,
'visible_on_front' => 0,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
]
);
`
- Magento is setup with 2 store configuration. [Default Store & My Store]
- Attribute
ced_profile_id
has value 'blank' in All Store Views ( i.e. for Admin store ID - 0), and value '2' for Default Store ( i.e. ID - 1). - On loading product collection with following code:
$storeId = 1; \** @var Magento\Catalog\Model\ResourceModel\Product\Collection $collection **\ $collection->setStoreId($storeId); $collection->addAttributeToSelect(['ced_profile_id']); $products = $collection->getData();
- Environment:
- Magento CE 2.2.5
- PHP 7.09
- MYSQL 5.7
Steps to reproduce
- Create a store-wise user-defined attribute.
- Have blank value for admin store (i.e. all store views, ID - 0). and Have 'some value' for Default Store i.e. ID - 1.
- Load Product collection by setting store id - 1, will get no values for default store - 1 for store -wise user defined attributes.
Expected result
1.$products have 2 attribute for 'ced_profile_id'.
Actual result
- $products have null attribute for 'ced_profile_id'.
- The Product collection final get SQL query search for Null value in admin store, while there is no row in admin store entity table for blank values. Add a row with null value for admin store and I am able to get the default store values.
In above image, entity_id 2,3,4 have null values for admin store - 0 and collection can get the default store values.
While entity_id 1 don't have a row incatalog_product_entity_varchar
, hence I am not able to get values in product collection for store id 1 i.e. Default Store .
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release