Merge branch 'master' of https://github.com/lovenunu/thelia into yochima-branch

This commit is contained in:
Guillaume Barral
2014-06-19 09:27:56 +02:00

View File

@@ -9,6 +9,8 @@ use Thelia\Coupon\FacadeInterface;
use Thelia\Condition\ConditionCollection; use Thelia\Condition\ConditionCollection;
use Thelia\Coupon\Type\RemoveXAmount; use Thelia\Coupon\Type\RemoveXAmount;
use Thelia\Coupon\Type\RemoveXPercent; use Thelia\Coupon\Type\RemoveXPercent;
use Thelia\Model\ModuleQuery;
use Thelia\Model\OrderAddress;
if (php_sapi_name() != 'cli') { if (php_sapi_name() != 'cli') {
throw new \Exception('this script can only be launched with cli sapi'); throw new \Exception('this script can only be launched with cli sapi');
@@ -148,6 +150,7 @@ try {
\Thelia\Model\ContentDocumentQuery::create()->find()->delete(); \Thelia\Model\ContentDocumentQuery::create()->find()->delete();
\Thelia\Model\CouponQuery::create()->find()->delete(); \Thelia\Model\CouponQuery::create()->find()->delete();
\Thelia\Model\OrderQuery::create()->find()->delete();
$stmt = $con->prepare("SET foreign_key_checks = 1"); $stmt = $con->prepare("SET foreign_key_checks = 1");
@@ -492,6 +495,111 @@ try {
} }
} }
echo "Creating orders\n";
$colissimo_id = ModuleQuery::create()->
filterByCode("Colissimo")
->findOne()
->getId();
$cheque_id = ModuleQuery::create()
->filterByCode("Cheque")
->findOne()
->getId();
for ($i=0; $i < 50; ++$i) {
$placedOrder = new \Thelia\Model\Order();
$deliveryOrderAddress = new OrderAddress();
$deliveryOrderAddress
->setCustomerTitleId(mt_rand(1,3))
->setCompany($faker->text(15))
->setFirstname($faker->firstname)
->setLastname($faker->lastname)
->setAddress1($faker->streetAddress)
->setAddress2($faker->streetAddress)
->setAddress3($faker->streetAddress)
->setPhone($faker->phoneNumber)
->setZipcode($faker->postcode)
->setCity($faker->city)
->setCountryId(64)
->save($con)
;
$invoiceOrderAddress = new OrderAddress();
$invoiceOrderAddress
->setCustomerTitleId(mt_rand(1,3))
->setCompany($faker->text(15))
->setFirstname($faker->firstname)
->setLastname($faker->lastname)
->setAddress1($faker->streetAddress)
->setAddress2($faker->streetAddress)
->setAddress3($faker->streetAddress)
->setPhone($faker->phoneNumber)
->setZipcode($faker->postcode)
->setCity($faker->city)
->setCountryId(64)
->save($con)
;
$placedOrder
->setDeliveryOrderAddressId($deliveryOrderAddress->getId())
->setInvoiceOrderAddressId($invoiceOrderAddress->getId())
->setDeliveryModuleId($colissimo_id)
->setPaymentModuleId($cheque_id)
->setStatusId(mt_rand(1, 5))
->setCurrency(
\Thelia\Model\CurrencyQuery::create()
->addAscendingOrderByColumn('RAND()')
->findOne()
)
->setCustomer(
\Thelia\Model\CustomerQuery::create()
->addAscendingOrderByColumn('RAND()')
->findOne()
)
->setDiscount(mt_rand(0, 10))
->setLang(
\Thelia\Model\LangQuery::create()
->addAscendingOrderByColumn('RAND()')
->findOne()
)
->setPostage(mt_rand(1, 50))
;
$placedOrder->save($con);
for ($j=0; $j < mt_rand(1, 10); ++$j) {
$pse = \Thelia\Model\ProductSaleElementsQuery::create()
->addAscendingOrderByColumn('RAND()')
->findOne();
$product = $pse->getProduct();
$orderProduct = new \Thelia\Model\OrderProduct();
$orderProduct
->setOrderId($placedOrder->getId())
->setProductRef($product->getRef())
->setProductSaleElementsRef($pse->getRef())
->setTitle($product->getTitle())
->setChapo($product->getChapo())
->setDescription($product->getDescription())
->setPostscriptum($product->getPostscriptum())
->setQuantity(mt_rand(1, 10))
->setPrice($price=mt_rand(1, 100))
->setPromoPrice(mt_rand(1, $price))
->setWasNew($pse->getNewness())
->setWasInPromo(rand(0,1) == 1)
->setWeight($pse->getWeight())
->setTaxRuleTitle($faker->text(20))
->setTaxRuleDescription($faker->text(50))
->setEanCode($pse->getEanCode())
->save($con);
}
}
echo "Generating coupons fixtures\n"; echo "Generating coupons fixtures\n";
generateCouponFixtures($thelia); generateCouponFixtures($thelia);