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


PHP Product::getInstanceByID方法代码示例

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


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

示例1: create

 /**
  * @role create
  */
 public function create()
 {
     $request = $this->getRequest();
     $rpp = RecurringProductPeriod::getNewInstance(Product::getInstanceByID((int) $request->get('productID'), ActiveRecord::LOAD_DATA));
     $rpp->position->set(1000);
     return $this->save($rpp);
 }
开发者ID:saiber,项目名称:livecart,代码行数:10,代码来源:RecurringProductPeriodController.php

示例2: add_to_cart

 public function add_to_cart()
 {
     $request = $this->application->getRequest();
     $productID = $request->get('productID');
     $customerOrderID = $request->get('customerOrderID');
     $count = $request->get('count');
     if (!isset($customerOrderID) && intval($customerOrderID == 0)) {
         throw new Exception('Order ID is required');
     }
     $order = CustomerOrder::getInstanceById($customerOrderID);
     $order->load(true);
     $order->loadAll();
     //throw new Exception('order : ' . $order->getTotal(true));
     $product = Product::getInstanceByID($productID, true, true);
     $product->load(true);
     //$variations = !$product->parent->get() ? $product->getVariationData($this->application) : array('1','2');
     //throw new Exception('variation ' . json_encode($variations) . ' parent : ' . $product->getID() . ' productID ' . $productID);
     if (!$product->isAvailable()) {
         throw new Exception('Product ' . $productID . ' is not Available ');
     } else {
         if ($count < $product->getMinimumQuantity()) {
             $count = $product->getMinimumQuantity();
         }
         ActiveRecordModel::beginTransaction();
         $item = $order->addProduct($product, $count);
         if ($item instanceof OrderedItem) {
             if ($order->isMultiAddress->get()) {
                 $item->save();
             }
         }
         if ($product->parent->get()) {
             $order->mergeItems();
         } else {
             $item->save();
         }
         //$order->mergeItems();
         $order->getTotal(true);
         $order->totalAmount->set($order->getTotal(true));
         $order->getTaxAmount();
         $order->save(true);
         ActiveRecordModel::commit();
     }
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($item->getID() > 0) {
         $parser = $this->getParser();
         $apiFieldNames = $parser->getApiFieldNames();
         $selFilter = new ARSelectFilter();
         $selFilter->mergeCondition(new EqualsCond(new ARFieldHandle('OrderedItem', 'ID'), $item->getID()));
         $orderedItem = OrderedItem::getRecordSetArray('OrderedItem', $selFilter);
         while ($item = array_shift($orderedItem)) {
             $orderedItemXml = $response->addChild('ordered_item');
             foreach ($item as $k => $v) {
                 if (in_array($k, $apiFieldNames)) {
                     $orderedItemXml->addChild($k, htmlentities($v));
                 }
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
开发者ID:saiber,项目名称:www,代码行数:60,代码来源:OrderedItemApi.php

示例3: getKeywordsString

 protected function getKeywordsString($array)
 {
     if (isset($array['Product'])) {
         $array = $array['Product'];
     }
     if (empty($array['sku'])) {
         return null;
     }
     if (is_string($array['name'])) {
         $array['name_lang'] = $array['name'];
     }
     if (isset($array['DefaultImage']) && is_array($array['DefaultImage']['Product']['name']) && !empty($array['DefaultImage']['Product']['name']['en'])) {
         $array['name_lang'] = $array['DefaultImage']['Product']['name']['en'];
     }
     if (!empty($array['parentID']) && empty($array['Parent'])) {
         $array['Parent'] = Product::getInstanceByID($array['parentID'], true)->toArray();
     }
     if (!empty($array['Parent']['name_lang']) && empty($array['name_lang'])) {
         $array['name_lang'] = $array['Parent']['name_lang'];
     }
     $name = isset($array['name_lang']) ? $array['name_lang'] : array_shift($array['name']);
     //if (!$name) { var_dump($array); exit; }
     $str = $name . '-' . $array['sku'];
     //var_dump($str);
     if ($str) {
         $str = preg_replace('/[^a-zA-Z0-9_\\-]/', '', urldecode(createHandleString($str)));
     }
     return $str && strlen($str) > 0 ? $str : null;
 }
开发者ID:saiber,项目名称:www,代码行数:29,代码来源:SeoImagePlugin.php

示例4: process

 public function process()
 {
     AddRatingFieldToSchema::process();
     $main = Product::getInstanceByID($this->request->get('id'), true);
     if ($main->parent->get()) {
         $main->parent->get()->load();
         $var = $main->toArray();
         $var['custom'] = $main->custom->get();
         $this->request->set('variation', $var);
         $this->request->set('activeVariationID', $this->request->get('id'));
         $main = $main->parent->get();
         $this->request->set('id', $main->getID());
         $productArray = $main->toArray();
         $handle = empty($productArray['URL']) ? $productArray['name_lang'] : $productArray['URL'];
         $this->request->set('producthandle', $handle);
     }
     ActiveRecord::clearPool();
     $variations = $main->getRelatedRecordSet('Product', select());
     $handle = $main->URL->get() ? $main->URL->get() : $main->getValueByLang('name', 'en');
     foreach ($variations as $variation) {
         $variation->setValueByLang('name', 'en', $main->getValueByLang('name', 'en') . ' ' . $variation->sku->get());
         $variation->URL->set($handle . ' ' . $variation->sku->get());
         $variation->parent->set(null);
     }
     $variations->toArray();
 }
开发者ID:saiber,项目名称:www,代码行数:26,代码来源:PreloadVariations.php

示例5: delete

 public function delete()
 {
     $product = Product::getInstanceByID($this->request->get('id'), ActiveRecord::LOAD_DATA, array('Category'));
     $category = Category::getInstanceByID($this->request->get('categoryId'), ActiveRecord::LOAD_DATA);
     $relation = ActiveRecordModel::getInstanceById('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $category->getID()));
     $relation->delete();
     return new JSONResponse(array('data' => $relation->toFlatArray()));
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:ProductCategoryController.php

示例6: specification

 public function specification()
 {
     $request = $this->application->getRequest();
     $productID = $request->get('ID');
     $product = Product::getInstanceByID($productID, Product::LOAD_DATA, Product::LOAD_REFERENCES);
     $product->load();
     throw new Exception(' product ' . json_encode($product->getSpecification()));
 }
开发者ID:saiber,项目名称:www,代码行数:8,代码来源:ProductApi.php

示例7: process

 public function process()
 {
     $custom = $this->request->get('custom');
     foreach (json_decode($this->request->get('items')) as $key => $id) {
         $prod = Product::getInstanceByID($id, true);
         $prod->custom->set($custom[$key]);
         $prod->save();
     }
 }
开发者ID:saiber,项目名称:www,代码行数:9,代码来源:SaveCustomVariationFields.php

示例8: create

 public function create()
 {
     $parentId = $this->request->get('parentID', false);
     if (substr($parentId, 0, 1) == 'c') {
         $parent = Category::getInstanceByID(substr($parentId, 1));
     } else {
         $parent = Product::getInstanceByID($parentId);
     }
     $productOption = ProductOption::getNewInstance($parent);
     return $this->save($productOption);
 }
开发者ID:GregerA,项目名称:livecart,代码行数:11,代码来源:ProductOptionController.php

示例9: index

 public function index()
 {
     $productID = (int) $this->request->get('id');
     $product = Product::getInstanceByID($productID, ActiveRecord::LOAD_DATA);
     $response = new ActionResponse();
     $response->set('ownerID', $productID);
     $response->set('categoryID', $product->category->get()->getID());
     $response->set('items', ProductBundle::getBundledProductArray($product));
     $currency = $this->application->getDefaultCurrency();
     $response->set('total', $currency->getFormattedPrice(ProductBundle::getTotalBundlePrice($product, $currency)));
     return $response;
 }
开发者ID:saiber,项目名称:livecart,代码行数:12,代码来源:ProductBundleController.php

示例10: create

 /**
  * @role update
  */
 public function create()
 {
     $product = Product::getInstanceByID((int) $this->request->get('productID'));
     if ($uploadFile = $this->request->get('uploadFile')) {
         $tmpPath = $uploadFile['tmp_name'];
         $name = $uploadFile['name'];
     } else {
         $tmpPath = null;
         $name = basename($this->request->get('filePath'));
     }
     $productFile = ProductFile::getNewInstance($product, $tmpPath, $name, $this->request->get('filePath'));
     return $this->save($productFile);
 }
开发者ID:saiber,项目名称:www,代码行数:16,代码来源:ProductFileController.php

示例11: index

 public function index()
 {
     //error_reporting(E_ALL);ini_set('display_errors', 1);
     $product = Product::getInstanceByID($this->request->get('id'), true);
     $mirror = null;
     foreach ($product->getRelatedRecordSetArray('ProductImage', select()) as $image) {
         if ($image['title_lang'] == 'Virtual Mirror') {
             $mirror = $image['urls'][3];
         }
     }
     if ($mirror) {
         $response = new BlockResponse();
         $response->set('mirror', $mirror);
         return $response;
     }
 }
开发者ID:saiber,项目名称:www,代码行数:16,代码来源:MirrorController.php

示例12: add

 /**
  * Creates new relationship
  *
  * @role update
  */
 public function add()
 {
     $productID = $this->request->get('relatedownerID');
     $ownerID = $this->request->get('id');
     $list = ActiveRecordModel::getInstanceById('ProductList', $ownerID, ActiveRecordModel::LOAD_DATA);
     $product = Product::getInstanceByID($productID, Product::LOAD_DATA, array('ProductImage'));
     if (!$list->contains($product)) {
         $list->addProduct($product);
         $response = new ActionResponse();
         $response->set('product', $product->toArray());
         $response->set('added', true);
         return $response;
     } else {
         return new JSONResponse(array('error' => $this->translate('_err_multiple')));
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:21,代码来源:ProductListItemController.php

示例13: getBestsellerData

 private function getBestsellerData($sql, $order = 'DESC')
 {
     $this->setChartType(self::TABLE);
     $q = $this->getQuery($sql);
     $f = $q->getFilter();
     $f->resetOrder();
     $f->resetGrouping();
     $f->setOrder(new ARExpressionHandle('cnt'), $order);
     $q->addField('OrderedItem.productID');
     $f->setGrouping(new ARExpressionHandle('OrderedItem.productID'));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), 1));
     $f->setLimit(self::TABLE_LIMIT);
     $q->joinTable('CustomerOrder', 'OrderedItem', 'ID', 'customerOrderID');
     $this->getReportData($q);
     $ids = array();
     foreach ($this->values as $product) {
         $ids[$product['productID']] = $product['cnt'];
     }
     // fetch product details
     $fields = array_flip(array('sku', 'name', 'cnt'));
     $products = ActiveRecordModel::getRecordSetArray('Product', new ARSelectFilter(new INCond(new ARFieldHandle('Product', 'ID'), array_keys($ids))), array('Parent'));
     ProductSet::loadVariationsForProductArray($products);
     foreach ($products as $product) {
         $product['cnt'] = $ids[$product['ID']];
         if (empty($product['name'])) {
             if (!empty($product['parentID'])) {
                 $parent = Product::getInstanceByID($product['parentID'], true);
                 $product['name'] = $parent->getValueByLang('name');
             } else {
                 $product['name'] = '';
             }
         }
         if (isset($product['variationValues'])) {
             $product['name'] .= ' (' . implode(' / ', $product['variationValues']) . ')';
         }
         // array_merge to put all array values in the same order
         $ids[$product['ID']] = array_merge($fields, array_intersect_key($product, $fields));
     }
     $this->values = $ids;
 }
开发者ID:saiber,项目名称:livecart,代码行数:40,代码来源:BestsellerReport.php

示例14: add

 /**
  * Creates new relationship
  *
  * @role update
  */
 public function add()
 {
     $productID = $this->request->get('relatedownerID');
     $ownerID = $this->request->get('id');
     $owner = Product::getInstanceByID($ownerID, Product::LOAD_DATA);
     $product = Product::getInstanceByID($productID, Product::LOAD_DATA, array('ProductImage'));
     if ($product->isBundle()) {
         return new JSONResponse(array('error' => $this->translate('_err_bundle_with_bundle')));
     }
     if (!ProductBundle::hasRelationship($owner, $product)) {
         $instance = ProductBundle::getNewInstance($owner, $product);
         if (!$instance) {
             return new JSONResponse(array('error' => $this->translate('_err_add_to_itself')));
         }
         $instance->save();
         $response = new ActionResponse();
         $response->set('product', $product->toArray());
         $response->set('added', true);
         $response->set('total', $this->getTotal($owner));
         return $response;
     } else {
         return new JSONResponse(array('error' => $this->translate('_err_multiple')));
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:29,代码来源:ProductBundleItemController.php

示例15: countTabsItems

 public function countTabsItems()
 {
     ClassLoader::import('application.model.product.*');
     $product = Product::getInstanceByID((int) $this->request->get('id'), ActiveRecord::LOAD_DATA);
     return new JSONResponse(array('tabProductBundle' => count(ProductBundle::getBundledProductArray($product)), 'tabProductRelationship' => $product->getRelationships(ProductRelationship::TYPE_CROSS)->getTotalRecordCount(), 'tabProductUpsell' => $product->getRelationships(ProductRelationship::TYPE_UP)->getTotalRecordCount(), 'tabProductFiles' => $product->getFiles(false)->getTotalRecordCount(), 'tabProductImages' => count($product->getImageArray()), 'tabProductOptions' => $product->getOptions()->getTotalRecordCount(), 'tabProductReviews' => $product->getRelatedRecordCount('ProductReview'), 'tabProductCategories' => $product->getRelatedRecordCount('ProductCategory') + 1, 'tabProductVariations' => $product->getRelatedRecordCount('Product', new ARSelectFilter(new EqualsCond(new ARFieldHandle('Product', 'isEnabled'), true)))));
 }
开发者ID:saiber,项目名称:livecart,代码行数:6,代码来源:ProductController.php


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