private function generateProduct()
 {
     $product = new Product();
     $name = array();
     for ($i = 0; $i < rand(3, 6); $i++) {
         array_push($name, $this->genstr(rand(3, 8)));
     }
     $product->setName(implode(' ', $name));
     $product->setPrice(rand(32, 999) / 10);
     $product->setPriceDiscounted($product->getPrice() * 0.9);
     $product->setSoldNo(rand(0, 500));
     $product->setUpdateAt($this->rand_date('2013-01-01', '2015-10-06'));
     $product->setBrand($this->genstr(rand(3, 8)));
     $product->setInventory(rand(0, 200));
     $product->setDescription($this->genstr(rand(3, 8)) . ' ' . $this->genstr(rand(3, 8)) . ' ' . $this->genstr(rand(3, 8)));
     $product->setProductKey(substr(uniqid(), 0, 10));
     $product->setWeight(rand(0, 1200));
     $product->setClick(rand(0, 1000));
     $product->setImageLink(uniqid());
     return $product;
 }
示例#2
0
 public function clickIncrement(Product $product)
 {
     $product->setClick($product->getClick() + 1);
     $this->em->persist($product);
     $this->em->flush();
 }