/** * Returns a usable customer number * * @return string */ protected function getCustomerNumber() { if ($this->BillingAddress->getNumber() != '') { return $this->BillingAddress->getNumber(); } else { return PlentymarketsUtils::getExternalCustomerID($this->Customer->getId()); } }
/** * Deletes all dummy customer entity */ private function deleteDummyCustomer(\Shopware\Models\Customer\Customer $customer) { $billingId = Shopware()->Db()->fetchOne('SELECT id FROM s_user_billingaddress WHERE userID = ?', array($customer->getId())); $shippingId = Shopware()->Db()->fetchOne('SELECT id FROM s_user_shippingaddress WHERE userID = ?', array($customer->getId())); if ($billingId) { Shopware()->Db()->delete('s_user_billingaddress_attributes', 'billingID = ' . $billingId); Shopware()->Db()->delete('s_user_billingaddress', 'id = ' . $billingId); } if ($shippingId) { Shopware()->Db()->delete('s_user_shippingaddress_attributes', 'shippingID = ' . $shippingId); Shopware()->Db()->delete('s_user_shippingaddress', 'id = ' . $shippingId); } Shopware()->Db()->delete('s_core_payment_data', 'user_id = ' . $customer->getId()); Shopware()->Db()->delete('s_user_attributes', 'userID = ' . $customer->getId()); Shopware()->Db()->delete('s_user', 'id = ' . $customer->getId()); }
public function testCanCreateEntityWithNewGroup() { $this->em->clear(); $groupKey = $this->generateRandomString(5); $group = new Group(); $group->setKey($groupKey); $customer = new Customer(); $customer->setGroup($group); $this->assertEmpty($customer->getId()); $this->assertEquals($group, $customer->getGroup()); $this->assertEmpty($customer->getGroup()->getId()); $this->assertEquals($groupKey, $customer->getGroup()->getKey()); return $customer; }
/** * @depends testCanCreateEntity */ public function testLazyLoad(Shopware\Models\Customer\Customer $customer) { $customerId = $customer->getId(); $groupKey = $customer->getGroup()->getKey(); $customer = null; $this->em->clear(); /** @var Customer $customer */ $customer = $this->em->getRepository('Shopware\\Models\\Customer\\Customer')->find($customerId); $group = $customer->getGroup(); $this->assertEquals($customer->getId(), $customerId); $this->assertEquals($group->getKey(), $groupKey); $this->assertEquals($customer->getGroupKey(), $groupKey); $this->assertEquals($customer->getGroupKey(), $group->getKey()); }
/** * @param $mail * @param null|\Shopware\Models\Customer\Customer $customer * @param null|int $shopId * @return bool */ public function isEmailUnique($mail, $customer = null, $shopId = null) { $customerId = null; if ($customer) { $customerId = $customer->getId(); if ($customer->getShop()) { $shopId = $customer->getShop()->getId(); } // If accountmode is 1 (no real user account), email is allowed to be non-unique if ($customer->getAccountMode() == 1) { return true; } } $query = $this->getRepository()->getValidateEmailQuery($mail, $customerId, $shopId); $customer = $query->getArrayResult(); return empty($customer); }