File tree Expand file tree Collapse file tree 1 file changed +22
-15
lines changed
setup/src/Magento/Setup/Model/FixtureGenerator Expand file tree Collapse file tree 1 file changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -124,24 +124,31 @@ private function getCustomerAddressEntityHandler()
124124 */
125125 private function addDefaultAddresses ()
126126 {
127- $ this ->getConnection ()->query (
128- sprintf (
129- '
130- update `%s` customer
131- join (
132- select
133- parent_id, min(entity_id) as min, max(entity_id) as max
134- from `%s`
135- group by parent_id
136- ) customer_address on customer_address.parent_id = customer.entity_id
127+ $ batchSize = 10000 ;
128+ $ customerTableName = $ this ->resourceConnection ->getTableName ('customer_entity ' );
129+ $ customerAddressTableName = $ this ->resourceConnection ->getTableName ('customer_address_entity ' );
130+ $ customerMaxId = $ this ->getConnection ()->fetchOne ("select max(entity_id) from ` $ customerTableName` " );
131+ for ($ i = 1 ; $ i < $ customerMaxId ; $ i += $ batchSize ) {
132+ $ this ->getConnection ()->query (
133+ "
134+ update ` $ customerTableName` customer
135+ join (
136+ select
137+ parent_id, min(entity_id) as min, max(entity_id) as max
138+ from ` $ customerAddressTableName`
139+ group by parent_id
140+ ) customer_address on customer_address.parent_id = customer.entity_id
137141 set
138142 customer.default_billing = customer_address.min,
139143 customer.default_shipping = customer_address.max
140- ' ,
141- $ this ->resourceConnection ->getTableName ('customer_entity ' ),
142- $ this ->resourceConnection ->getTableName ('customer_address_entity ' )
143- )
144- );
144+ where entity_id between :min and :max
145+ " ,
146+ [
147+ 'min ' => $ i ,
148+ 'max ' => $ i + $ batchSize
149+ ]
150+ );
151+ }
145152 }
146153
147154 /**
You can’t perform that action at this time.
0 commit comments