$t->comment('/////////////////////////////////////////////////////////////////////////////'); $numberFormat = new sfNumberFormat(sfContext::getInstance()->getUser()->getCulture()); // Tools $tools = new rtShopVoucherRangeTestTools(); // Tax and shipping configurations sfConfig::set('app_rt_shop_tax_rate', 10); sfConfig::set('app_rt_shop_tax_mode', 'exclusive'); sfConfig::set('app_rt_shop_shipping_charges', array('default' => 20, 'AU' => 10, 'NZ' => 10)); // Add some data to play with... $tools->clean(); // Products try { $prod1 = new rtShopProduct(); $prod1->setTitle('Product A'); $prod1->save(); $prod2 = new rtShopProduct(); $prod2->setTitle('Product B'); $prod2->save(); } catch (Exception $e) { throw new sfException('Products could not be added! Please check.'); } // Categories try { $cat1 = new rtShopCategory(); $cat1->setTitle('Home'); $cat1->setRootId(1); $cat1->setLft(1); $cat1->setRgt(4); $cat1->setLevel(0); $cat1->save(); $cat2 = new rtShopCategory();
/** * Return all related products, ordered and published. * * @param rtShopProduct $rt_shop_product * @param Doctrine_Query $query * @return Doctrine_Collection */ public function addRelatedProductQuery(rtShopProduct $rt_shop_product, Doctrine_Query $query = null) { $query = $this->addPublishedQuery($query); $query->leftJoin('page.rtShopProducts related')->leftJoin('page.rtShopProductToProduct link')->orderBy('link.position ASC')->andWhere('link.product_id = ?', $rt_shop_product->getId()); return $query; }
$prod2 = new rtShopProduct(); $prod2->setTitle('Product B'); $prod2->save(); $prod3 = new rtShopProduct(); $prod3->setTitle('Product C'); $prod3->save(); $prod4 = new rtShopProduct(); $prod4->setTitle('Product D'); $prod4->save(); $prod5 = new rtShopProduct(); $prod5->setTitle('Product E'); $prod5->save(); $prod6 = new rtShopProduct(); $prod6->setTitle('Product F'); $prod6->save(); $prod7 = new rtShopProduct(); $prod7->setTitle('Product G'); $prod7->save(); } catch (Exception $e) { throw new sfException('Products could not be added! Please check.'); } try { $cat1 = new rtShopCategory(); $cat1->setTitle('Home'); $cat1->setRootId(1); $cat1->setLft(1); $cat1->setRgt(4); $cat1->setLevel(0); $cat1->save(); $cat2 = new rtShopCategory(); $cat2->setTitle('Category A');
$t->comment('Case #1: Gift Voucher only (no taxes, promotions, etc.)'); $t->comment('Case #2: Gift Voucher & product (no taxes, promotions, etc.)'); $t->comment('Case #3: Gift Voucher & product (no taxes, promotions, etc.) | voucher set in cart (Special case: total order value comes to zero)'); $t->comment('Case #4: Gift Voucher & product (tax | shipping) | voucher set in cart'); $t->comment('Case #5: Gift Voucher & product (tax | shipping | cart promotion) | voucher set in cart'); $t->comment('Case #6: Gift Voucher & products (tax | shipping | cart promotion) | voucher set in cart'); // Add data rtShopComplexOrder5TestTools::clean(); try { $prod1 = new rtShopProduct(); $prod1->setTitle('Product A'); $prod1->save(); $prod2 = new rtShopProduct(); $prod2->setTitle('Product B'); $prod2->save(); $prod3 = new rtShopProduct(); $prod3->setTitle('Product C'); $prod3->save(); } catch (Exception $e) { throw new sfException('Products could not be added! Please check.'); } try { $cat1 = new rtShopCategory(); $cat1->setTitle('Home'); $cat1->setRootId(1); $cat1->setLft(1); $cat1->setRgt(4); $cat1->setLevel(0); $cat1->save(); $cat2 = new rtShopCategory(); $cat2->setTitle('Category A');