diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 5fb1847a2..949010384 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -234,12 +234,14 @@ class Cart implements EventSubscriberInterface protected function generateCookie() { + $id = null; if (ConfigQuery::read("cart.session_only", 0) == 0) { $id = uniqid('', true); setcookie("thelia_cart", $id, time()+ConfigQuery::read("cookie.lifetime", 60*60*24*365)); - return $id; } + return $id; + } } diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index b6379380b..5d36b639a 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -45,6 +45,7 @@ class Customer extends BaseCustomer implements UserInterface * @param string $phone customer phone number * @param string $cellphone customer cellphone number * @param string $zipcode customer zipcode + * @param string $city * @param int $countryId customer country id (from Country table) * @param string $email customer email, must be unique * @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password @@ -53,7 +54,7 @@ class Customer extends BaseCustomer implements UserInterface * @param null $sponsor * @param int $discount */ - public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this ->setTitleId($titleId) @@ -79,7 +80,7 @@ class Customer extends BaseCustomer implements UserInterface $address = new Address(); $address - ->setCustomerTitleId($titleId) + ->setTitleId($titleId) ->setFirstname($firstname) ->setLastname($lastname) ->setAddress1($address1) @@ -119,9 +120,15 @@ class Customer extends BaseCustomer implements UserInterface return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true); } + /** + * create hash for plain password and set it in Customer object + * + * @param string $password plain password before hashing + * @return $this|Customer + * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + */ public function setPassword($password) { - \Thelia\Log\Tlog::getInstance()->debug($password); if ($this->isNew() && ($password === null || trim($password) == "")) { throw new InvalidArgumentException("customer password is mandatory on creation"); } diff --git a/install/faker.php b/install/faker.php index 85a338ebe..de3992c68 100755 --- a/install/faker.php +++ b/install/faker.php @@ -20,6 +20,28 @@ try { ->find(); $product->delete(); + $customer = Thelia\Model\CustomerQuery::create() + ->find(); + $customer->delete(); + + $customer = new Thelia\Model\Customer(); + $customer->createOrUpdate( + 1, + "thelia", + "thelia", + "5 rue rochon", + "", + "", + "0102030405", + "0601020304", + "63000", + "clermont-ferrand", + 64, + "test@thelia.net", + "azerty" + ); + + //first category $sweet = new Thelia\Model\Category(); $sweet->setParent(0); diff --git a/install/thelia.sql b/install/thelia.sql index bba595ae6..8c01bc96f 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1271,7 +1271,7 @@ DROP TABLE IF EXISTS `cart`; CREATE TABLE `cart` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `token` VARCHAR(255) NOT NULL, + `token` VARCHAR(255), `customer_id` INTEGER, `address_delivery_id` INTEGER, `address_invoice_id` INTEGER, diff --git a/local/config/schema.xml b/local/config/schema.xml index 7db8aa26b..935a156ff 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -923,7 +923,7 @@