@@ -65,39 +65,19 @@ public function addCustomerData()
65
65
{
66
66
// alias => attribute_code
67
67
$ attributes = [
68
- 'customer_lastname ' => 'lastname ' ,
69
- 'customer_firstname ' => 'firstname ' ,
70
- 'customer_email ' => 'email ' ,
68
+ 'customer_lastname ' => 'customer. lastname ' ,
69
+ 'customer_firstname ' => 'customer. firstname ' ,
70
+ 'customer_email ' => 'customer. email ' ,
71
71
];
72
72
73
- foreach ( $ attributes as $ alias => $ attributeCode ) {
74
- $ attribute = $ this ->_eavHelper -> getAttributeMetadata (
75
- \ Magento \ Customer \ Api \CustomerMetadataInterface:: ENTITY_TYPE_CUSTOMER ,
76
- $ attributeCode
77
- );
73
+ $ this -> getSelect ()-> joinLeft (
74
+ [ ' customer ' => $ this ->getConnection ()-> getTableName ( ' customer_entity ' )],
75
+ ' customer.entity_id=main_table.customer_id ' ,
76
+ $ attributes
77
+ );
78
78
79
- $ tableAlias = ' customer_ ' . $ attributeCode ;
79
+ $ this -> _fields = array_merge ( $ this -> _fields , $ attributes ) ;
80
80
81
- if ($ attribute ['backend_type ' ] == 'static ' ) {
82
- $ this ->getSelect ()->joinLeft (
83
- [$ tableAlias => $ attribute ['attribute_table ' ]],
84
- sprintf ('%s.entity_id=main_table.customer_id ' , $ tableAlias ),
85
- [$ alias => $ attributeCode ]
86
- );
87
- $ this ->_fields [$ alias ] = sprintf ('%s.%s ' , $ tableAlias , $ attributeCode );
88
- } else {
89
- $ joinConds = [
90
- sprintf ('%s.entity_id=main_table.customer_id ' , $ tableAlias ),
91
- $ this ->getConnection ()->quoteInto ($ tableAlias . '.attribute_id=? ' , $ attribute ['attribute_id ' ]),
92
- ];
93
- $ this ->getSelect ()->joinLeft (
94
- [$ tableAlias => $ attribute ['attribute_table ' ]],
95
- join (' AND ' , $ joinConds ),
96
- [$ alias => 'value ' ]
97
- );
98
- $ this ->_fields [$ alias ] = sprintf ('%s.value ' , $ tableAlias );
99
- }
100
- }
101
81
$ this ->setFlag ('has_customer_data ' , true );
102
82
return $ this ;
103
83
}
@@ -111,7 +91,7 @@ public function addCustomerData()
111
91
public function addWebsiteFilter ($ websiteIds )
112
92
{
113
93
if ($ this ->getFlag ('has_customer_data ' )) {
114
- $ this ->getSelect ()->where ('customer_email .website_id IN (?) ' , $ websiteIds );
94
+ $ this ->getSelect ()->where ('customer .website_id IN (?) ' , $ websiteIds );
115
95
}
116
96
return $ this ;
117
97
}
0 commit comments