public function testSearchByIdComplex() { $product = ProductQuery::create()->orderById(Criteria::ASC)->findOne(); if (null === $product) { $product = new \Thelia\Model\Product(); $product->setDefaultCategory(0); $product->setVisible(1); $product->setTitle('foo'); $product->save(); } $otherParameters = array("visible" => "*", "complex" => 1); $this->baseTestSearchById($product->getId(), $otherParameters); }
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; }
$productPrice->delete(); $stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt->execute(); //categories and products for ($i = 0; $i < 100; $i++) { $category = new Thelia\Model\Category(); $category->setParent(0); $category->setVisible(1); $category->setPosition($i); setI18n($faker, $category); $category->save(); for ($j = 0; $j < 10; $j++) { $product = new Thelia\Model\Product(); $product->setRef($category->getId() . '_' . $j . '_' . $faker->randomNumber(8)); $product->addCategory($category); $product->setVisible(1); $product->setPosition($j); setI18n($faker, $product); $product->save(); } } $con->commit(); } catch (Exception $e) { echo "error : " . $e->getMessage() . "\n"; $con->rollBack(); } function setI18n($faker, &$object, $fields = array('Title' => 20, 'Description' => 50)) { $localeList = array('fr_FR', 'en_US', 'es_ES', 'it_IT', 'de_DE'); foreach ($localeList as $locale) { $object->setLocale($locale);