當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProductCategory::getNewInstance方法代碼示例

本文整理匯總了PHP中ProductCategory::getNewInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProductCategory::getNewInstance方法的具體用法?PHP ProductCategory::getNewInstance怎麽用?PHP ProductCategory::getNewInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ProductCategory的用法示例。


在下文中一共展示了ProductCategory::getNewInstance方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     Category::recalculateProductsCount();
     $this->root = Category::getNewInstance(Category::getRootNode());
     $this->root->save();
     for ($k = 1; $k <= 2; $k++) {
         $cat = Category::getNewInstance($this->root);
         $cat->save();
         $this->categories[$k] = $cat;
     }
     $this->product = Product::getNewInstance($this->categories[1]);
     $this->product->save();
     $this->secondCategory = ProductCategory::getNewInstance($this->product, $this->categories[2]);
     $this->secondCategory->save();
 }
開發者ID:saiber,項目名稱:livecart,代碼行數:16,代碼來源:ProductCategoryTest.php

示例2: importAdditionalCategories

 private function importAdditionalCategories(CsvImportProfile $profile, Product $product, array $extraCategories)
 {
     $product->deleteRelatedRecordSet('ProductCategory');
     foreach ($extraCategories as $names) {
         ProductCategory::getNewInstance($product, $this->getCategoryByPath($profile, $names))->save();
     }
 }
開發者ID:GregerA,項目名稱:livecart,代碼行數:7,代碼來源:ProductImport.php

示例3: testAdditionalCategories

 /**
  *	@todo: doesn't work
  */
 public function testAdditionalCategories()
 {
     $customCategory = Category::getNewInstance(Category::getRootNode());
     $customCategory->save();
     $product = $this->product1;
     $this->order->addProduct($product, 1, true);
     $this->order->save();
     $condition = DiscountCondition::getNewInstance();
     $condition->isEnabled->set(true);
     $condition->conditionClass->set('RuleConditionContainsProduct');
     $condition->save();
     DiscountConditionRecord::getNewInstance($condition, $customCategory)->save();
     $this->assertEquals(0, count($this->order->getDiscountConditions(true)));
     ProductCategory::getNewInstance($product, $customCategory)->save();
     $condition->loadAll();
     //$this->assertEquals(1, count($this->order->getDiscountConditions(true)));
 }
開發者ID:saiber,項目名稱:livecart,代碼行數:20,代碼來源:DiscountConditionTest.php

示例4: testProductSyncMatchingProductExtraCat

 public function testProductSyncMatchingProductExtraCat()
 {
     for ($k = 0; $k <= 1; $k++) {
         $product = Product::getNewInstance($this->categories['1.2.1']);
         $product->sku->set($k);
         $product->save();
     }
     ClonedStoreCategory::getNewInstance($this->categories['1.2.2'], $this->stores[0])->save();
     ProductCategory::getNewInstance($product, $this->categories['1.2.1'])->save();
     $updater = $this->getUpdater();
     $updater->syncAll();
     $this->assertRecordCount('Product', 1);
 }
開發者ID:saiber,項目名稱:www,代碼行數:13,代碼來源:TestStoreCloning.php

示例5: testDiscountByAdditionalCategories

 public function testDiscountByAdditionalCategories()
 {
     $product = $this->products[1];
     $condition = DiscountCondition::getNewInstance();
     $condition->isEnabled->set(true);
     $condition->save();
     $actionCondition = DiscountCondition::getNewInstance();
     $actionCondition->isEnabled->set(true);
     $actionCondition->conditionClass->set('RuleConditionContainsProduct');
     $actionCondition->save();
     $action = DiscountAction::getNewInstance($condition);
     $action->actionCondition->set($actionCondition);
     $action->isEnabled->set(true);
     $action->type->set(DiscountAction::TYPE_ITEM_DISCOUNT);
     $action->amount->set(10);
     $action->actionClass->set('RuleActionPercentageDiscount');
     $action->save();
     $randomCategory = Category::getNewInstance(Category::getRootNode());
     $randomCategory->save();
     DiscountConditionRecord::getNewInstance($actionCondition, $randomCategory)->save();
     $this->order->addProduct($product, 1, true);
     $this->order->save();
     Category::recalculateProductsCount();
     $product->reload();
     $this->assertFalse(RuleCondition::create($actionCondition)->isProductMatching($product));
     $customCategory = Category::getNewInstance(Category::getRootNode());
     $customCategory->save();
     ProductCategory::getNewInstance($product, $customCategory)->save();
     DiscountConditionRecord::getNewInstance($actionCondition, $customCategory)->save();
     Category::recalculateProductsCount();
     $product->reload();
     $actionCondition->loadAll();
     $this->assertTrue(RuleCondition::create($actionCondition)->isProductMatching($product));
     $this->assertEquals(count($this->order->getDiscountActions(true)), 1);
     $this->assertEquals($this->products[1]->getPrice($this->usd) * 0.9, $this->order->getTotal(true));
     ActiveRecordModel::clearPool();
     $order = CustomerOrder::getInstanceByID($this->order->getID());
     $order->loadAll();
     $this->assertEquals($this->products[1]->getPrice($this->usd) * 0.9, $this->order->getTotal(true));
 }
開發者ID:saiber,項目名稱:livecart,代碼行數:40,代碼來源:OrderTest.php

示例6: importAdditionalCategories

 private function importAdditionalCategories(CsvImportProfile $profile, Product $product, $extraCategories)
 {
     $product->deleteRelatedRecordSet('ProductCategory');
     $instances = array();
     if (is_array($extraCategories)) {
         foreach ($extraCategories as $names) {
             $instances[] = $this->getCategoryByPath($profile, $names);
         }
     } else {
         if ($extraCategories instanceof Condition) {
             $instances = ActiveRecord::getRecordSet('Category', select($extraCategories));
         }
     }
     foreach ($instances as $cat) {
         ProductCategory::getNewInstance($product, $cat)->save();
     }
 }
開發者ID:saiber,項目名稱:www,代碼行數:17,代碼來源:ProductImport.php


注:本文中的ProductCategory::getNewInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。