当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductCategory::create方法代码示例

本文整理汇总了PHP中ProductCategory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductCategory::create方法的具体用法?PHP ProductCategory::create怎么用?PHP ProductCategory::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductCategory的用法示例。


在下文中一共展示了ProductCategory::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Product::create(['name' => 'Test Product', 'slug' => 'test-product', 'price' => 100, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rhoncus, turpis ac imperdiet dapibus, leo orci gravida neque, in malesuada elit libero eu sapien. Mauris sed sapien id sapien bibendum luctus et eu massa. Nulla egestas interdum magna non dignissim. Sed a laoreet purus, non rutrum augue. Proin laoreet eros nec elit mattis euismod. Aliquam facilisis, lacus blandit iaculis accumsan, leo quam sagittis nisi, non dapibus arcu libero efficitur turpis. In fringilla est nec sapien tempus suscipit. Suspendisse eget justo risus.']);
     Product::create(['name' => 'Uncategorized Product', 'slug' => 'uncategorized-product', 'price' => 200, 'description' => 'This product has no category.']);
     Category::create(['name' => 'Test Category', 'slug' => 'test-category']);
     ProductCategory::create(['product_id' => 1, 'category_id' => 1]);
 }
开发者ID:joeyemery,项目名称:ecommerce,代码行数:13,代码来源:DatabaseSeeder.php

示例2: get_current_category

 /**
  * Find the current category via its URL
  *
  * @return ProductCategory
  *
  */
 public static function get_current_category()
 {
     $segment = Controller::curr()->request->param('URLSegment');
     $return = null;
     if ($segment) {
         $return = ProductCategory::get()->filter('URLSegment', $segment)->first();
     }
     if (!$return) {
         $return = ProductCategory::create();
     }
     return $return;
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:18,代码来源:Catalogue_Controller.php

示例3: createProduct

 /**
  * create product
  *
  * @param string $sku			The sku of product
  * @param string $name			The name of product
  * @param array $categoryPaths	The category paths of product (e.g. $categories = array(array('cate2', 'cate3'), array('cate4', 'cate5', 'cate6'));
  * @param string $mageProductId //TODO
  * @param string $isFromB2B
  * @param string $shortDescr
  * @param string $fullDescr
  * @param string $brandName
  *
  * @throws Exception
  * @return string
  * @soapmethod
  */
 public function createProduct($sku, $name, $categoryPaths = array(), $mageProductId = '', $isFromB2B = false, $shortDescr = '', $fullDescr = '', $brandName = '')
 {
     $response = $this->_getResponse(UDate::now());
     try {
         Dao::beginTransaction();
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         //TODO
         if (Product::getBySku(trim($sku)) instanceof Product) {
             throw new Exception('sku "' . $sku . '" already exists');
         }
         $categories = array();
         if (is_array($categoryPaths)) {
             foreach ($categoryPaths as $categoryPath) {
                 $parentCategory = null;
                 foreach ($categoryPath as $categoryName) {
                     if (count($i = ProductCategory::getAllByCriteria('name = ?', array(trim($categoryName)), true, 1, 1)) > 0) {
                         $categories[$i[0]->getId()] = $category = $i[0];
                     } else {
                         $category = ProductCategory::create(trim($categoryName), trim($categoryName), $parentCategory);
                         $categories[$category->getId()] = $category;
                     }
                     $parentCategory = $category;
                 }
             }
         }
         // create product
         $product = Product::create(trim($sku), trim($name));
         // TODO
         foreach ($categories as $category) {
             $product->addCategory($category);
         }
         $response['status'] = self::RESULT_CODE_SUCC;
         $this->addCData('product', json_encode($product->getJson()), $response);
         Dao::commitTransaction();
     } catch (Exception $e) {
         Dao::rollbackTransaction();
         $response['status'] = self::RESULT_CODE_FAIL;
         $this->addCData('error', $e->getMessage(), $response);
     }
     return trim($response->asXML());
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:57,代码来源:APIProduct.php

示例4: injectProductCategory

 public function injectProductCategory()
 {
     $validator = Validator::make($data = Input::all(), ProductCategory::$rules);
     if ($validator->fails()) {
         return 'failt';
     }
     ProductCategory::create($data);
     return 'worked';
 }
开发者ID:NocturnalWare,项目名称:managedotband,代码行数:9,代码来源:ProductsController.php

示例5: setParent

 public function setParent(&$obj, $val, $record)
 {
     $title = strtolower(Convert::raw2sql($val));
     if ($title) {
         if ($parentpage = DataObject::get_one('ProductCategory', "LOWER(\"Title\") = '{$title}'", '"Created" DESC')) {
             // find or create parent category, if provided
             $obj->ParentID = $parentpage->ID;
             $obj->write();
             $obj->writeToStage('Stage');
             $obj->publish('Stage', 'Live');
             //TODO: otherwise assign it to the first prodcut group found
         } elseif (self::$createnewproductgroups) {
             //create parent product group
             $pg = ProductCategory::create();
             $pg->setTitle($title);
             $pg->ParentID = self::$parentpageid ? $parentpageid : 0;
             $pg->writeToStage('Stage');
             $pg->publish('Stage', 'Live');
             $obj->ParentID = $pg->ID;
             $obj->write();
             $obj->writeToStage('Stage');
             $obj->publish('Stage', 'Live');
         }
     }
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:25,代码来源:ProductBulkLoader.php

示例6: ProductCategory

<?php

require_once '../productCategory.php';
//from root/model/
$function = $_POST['function'];
$parent = @$_POST['parent'];
$parentIndex = @$_POST['parentIndex'];
$name = @$_POST['name'];
if ($function == "postNewEntry") {
    $category = new ProductCategory($name, $parent, $parentIndex);
    $category->create();
    echo "{$category->index}";
    //echo "obtainded info : $name , $parent , $parentIndex";
    //echo "$category->index is index, $category->parent";
}
if ($function == "createNewColor") {
    $colorName = $name;
    productCategory::createNewColor($colorName);
    echo productCategory::getLastColorIndex();
}
开发者ID:n-sakib,项目名称:juierp,代码行数:20,代码来源:productCategory.php

示例7: importProductCategories

 /**
  * Importing the category
  *
  * @param string $categoryId
  *
  * @return void|CatelogConnector
  */
 public function importProductCategories($categoryId = '')
 {
     $categories = $this->getCategoryLevel($categoryId);
     Log::logging(0, get_class($this), 'getting ProductCategories(mageId=' . $categoryId . ')', self::LOG_TYPE, '', __FUNCTION__);
     if (count($categories) === 0) {
         return;
     }
     try {
         $transStarted = false;
         try {
             Dao::beginTransaction();
         } catch (Exception $e) {
             $transStarted = true;
         }
         foreach ($categories as $category) {
             $mageId = trim($category->category_id);
             Log::logging(0, get_class($this), 'getting ProductCategory(mageId=' . $mageId . ')', self::LOG_TYPE, '', __FUNCTION__);
             $productCategory = ProductCategory::getByMageId($mageId);
             $category = $this->catalogCategoryInfo($mageId);
             if (!is_object($category)) {
                 continue;
             }
             $description = isset($category->description) ? trim($category->description) : trim($category->name);
             if (!$productCategory instanceof ProductCategory) {
                 Log::logging(0, get_class($this), 'found new category from magento(mageId=' . $mageId . ', name="' . $category->name . '"' . ')', self::LOG_TYPE, '', __FUNCTION__);
                 echo 'found new category from magento(mageId=' . $mageId . ', name="' . $category->name . '"' . ')' . "\n";
                 $productCategory = ProductCategory::create(trim($category->name), $description, ProductCategory::getByMageId(trim($category->parent_id)), true, $mageId);
             } else {
                 Log::logging(0, get_class($this), 'found existing category from magento(mageId=' . $mageId . ', name="' . $category->name . '", ID=' . $productCategory->getId() . ')', self::LOG_TYPE, '', __FUNCTION__);
                 echo 'found existing category from magento(mageId=' . $mageId . ', name="' . $category->name . '", ID=' . $productCategory->getId() . ')' . "\n";
                 $productCategory->setName(trim($category->name))->setDescription($description)->setParent(ProductCategory::getByMageId(trim($category->parent_id)));
             }
             $productCategory->setActive(trim($category->is_active) === '1')->setIncludeInMenu(isset($category->include_in_menu) && trim($category->include_in_menu) === '1')->setIsAnchor(trim($category->is_anchor) === '1')->setUrlKey(trim($category->url_key))->save();
             $this->importProductCategories(trim($category->category_id));
         }
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
     } catch (Exception $ex) {
         if ($transStarted === false) {
             Dao::rollbackTransaction();
         }
         throw $ex;
     }
     return $this;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:53,代码来源:CatelogConnector.php


注:本文中的ProductCategory::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。