Esempio n. 1
0
 public function testSearchById()
 {
     $category = CategoryQuery::create()->findOne();
     if (null === $category) {
         $category = new \Thelia\Model\Category();
         $category->setParent(0);
         $category->setVisible(1);
         $category->setTitle('foo');
         $category->save();
     }
     $otherParameters = array("visible" => "*");
     $this->baseTestSearchById($category->getId(), $otherParameters);
 }
Esempio n. 2
0
function createProduct($faker, Thelia\Model\Category $category, $position, $template, $brandIdList, &$productIdList, &$virtualProductList)
{
    $product = new Thelia\Model\Product();
    $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8));
    $product->addCategory($category);
    $product->setVisible(1);
    $productCategories = $product->getProductCategories();
    $collection = new \Propel\Runtime\Collection\Collection();
    $collection->prepend($productCategories[0]->setDefaultCategory(1));
    $product->setProductCategories($collection);
    $product->setVirtual(mt_rand(1, 5) > 1 ? 0 : 1);
    $product->setVisible(1);
    $product->setPosition($position);
    $product->setTaxRuleId(1);
    $product->setTemplate($template);
    $product->setBrandId($brandIdList[array_rand($brandIdList, 1)]);
    setI18n($product);
    $product->save();
    $productId = $product->getId();
    $productIdList[] = $productId;
    $image = new \Thelia\Model\ProductImage();
    $image->setProductId($productId);
    generate_image($image, 'product', $productId);
    $document = new \Thelia\Model\ProductDocument();
    $document->setProductId($productId);
    generate_document($document, 'product', $productId);
    if ($product->getVirtual() == 1) {
        $virtualProductList[$productId] = $document->getId();
    }
    return $product;
}