19 private $entityGeneratorFactory;
24 private $customerTemplateGenerator;
29 private $resourceConnection;
42 EntityGeneratorFactory $entityGeneratorFactory,
46 $this->entityGeneratorFactory = $entityGeneratorFactory;
47 $this->customerTemplateGenerator = $customerTemplateGenerator;
60 $this->entityGeneratorFactory
62 'entityType' => CustomerInterface::class,
64 'customer_entity' => [
65 'handler' => $this->getCustomerEntityHandler()
68 'customer_address_entity' => [
69 'handler' => $this->getCustomerAddressEntityHandler()
73 $this->customerTemplateGenerator,
81 $this->addDefaultAddresses();
91 private function getCustomerEntityHandler()
93 return function ($entityId, $entityNumber, $fixtureMap, $binds) {
97 array_fill(0, count($binds), $fixtureMap[
'customer_data'][
'customer'])
109 private function getCustomerAddressEntityHandler()
111 return function ($entityId, $entityNumber, $fixtureMap, $binds) {
114 array_fill(0, count($fixtureMap[
'customer_data'][
'addresses']), reset($binds)),
115 $fixtureMap[
'customer_data'][
'addresses']
125 private function addDefaultAddresses()
127 $this->getConnection()->query(
133 parent_id, min(entity_id) as min, max(entity_id) as max 136 ) customer_address on customer_address.parent_id = customer.entity_id 138 customer.default_billing = customer_address.min, 139 customer.default_shipping = customer_address.max 141 $this->resourceConnection->getTableName(
'customer_entity'),
142 $this->resourceConnection->getTableName(
'customer_address_entity')
150 private function getConnection()
152 if (
null === $this->connection) {
153 $this->connection = $this->resourceConnection->getConnection();
156 return $this->connection;
generate($customers, array $fixtureMap)
call_user_func($callable, $param)
__construct(EntityGeneratorFactory $entityGeneratorFactory, CustomerTemplateGenerator $customerTemplateGenerator, \Magento\Framework\App\ResourceConnection $resourceConnection)