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


PHP product::find方法代码示例

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


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

示例1: addItem

 function addItem()
 {
     global $router;
     $product_type = isset($this->params['product_type']) ? $this->params['product_type'] : 'product';
     $product = new product();
     //eDebug($this->params);
     //if we're trying to add a parent product ONLY, then we redirect to it's show view
     $c = null;
     if (isset($this->params['product_id']) && empty($this->params['children'])) {
         $c = $product->find('first', 'parent_id=' . $this->params['product_id']);
     }
     if (!empty($c->id)) {
         flash('message', gt("Please select a product and quantity from the options listed below to add to your cart."));
         redirect_to(array('controller' => 'store', 'action' => 'show', 'id' => $this->params['product_id']));
     }
     //check for multiple product adding
     if (isset($this->params['prod-quantity'])) {
         //we are adding multiple children, so we approach a bit different
         //we'll send over the product_id of the parent, along with id's and quantities of children we're adding
         foreach ($this->params['prod-quantity'] as $qkey => &$quantity) {
             if (in_array($qkey, $this->params['prod-check'])) {
                 //this might not be working...FJD
                 $child = new $product_type($qkey);
                 /*if ($quantity < $child->minimum_order_quantity)                       
                   {
                       flash('message', $child->title . " - " . $child->model . " has a minimum order quantity of " . $child->minimum_order_quantity . 
                       '. Your quantity has been adjusted accordingly.');
                       $quantity = $child->minimum_order_quantity;
                       
                   }*/
                 $this->params['children'][$qkey] = $quantity;
             }
             if (isset($child)) {
                 $this->params['product_id'] = $child->parent_id;
             }
         }
     }
     $product = new $product_type($this->params['product_id'], true, true);
     //need true here?
     //Check the Main Product quantity
     if (isset($this->params['quantity'])) {
         if ((int) $this->params['quantity'] < $product->minimum_order_quantity) {
             flash('message', gt("Please enter a quantity equal or greater than the minimum order quantity."));
             redirect_to(array('controller' => 'store', 'action' => 'show', 'id' => $this->params['product_id']));
         } else {
         }
     }
     if ($product->product_type == "product" || $product->product_type == "childProduct") {
         if (($product->hasOptions() || $product->hasUserInputFields()) && (!isset($this->params['options_shown']) || $this->params['options_shown'] != $product->id)) {
             // if we hit here it means this product type was missing some
             // information it needs to add the item to the cart..so we need to help
             // it display its addToCart form
             /*redirect_to(array(
             				'controller'=>'cart',
             				'action'=>'displayForm',
             				'form'=>'addToCart',
             				'product_id'=>$this->params['product_id'],
             				'product_type'=>$this->params['product_type'],
             				'children'=>serialize($this->params['children']), 
             		));*/
             $product->displayForm('addToCart', $this->params);
             return false;
         }
     }
     //product either has no options, user input fields, or has already seen and passed the options page, so we try adding to cart
     //it will validate and fail back to the options page if data is incorrect for whatever reason (eg, bad form post)
     //eDebug($this->params, true);
     //$this->params['qty'] = 1; //REMOVE ME
     if ($product->addToCart($this->params)) {
         if (empty($this->params['quick'])) {
             flash('message', gt("Added") . " " . $product->title . " " . gt("to your cart.") . " <a href='" . $router->makeLink(array('controller' => 'cart', 'action' => 'checkout'), false, true) . "'>" . gt("Click here to checkout now.") . "</a>");
             //expHistory::back();
             //eDebug(show_msg_queue(false),true);
             redirect_to(array('controller' => 'cart', 'action' => 'show'));
             //expHistory::lastNotEditable();
         } else {
             redirect_to(array('controller' => 'cart', 'action' => 'quickPay'));
         }
     } else {
         //expHistory::back();
     }
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:82,代码来源:cartController.php

示例2: get_id

 function get_id($id)
 {
     return product::find($id);
 }
开发者ID:dieka2501,项目名称:jip,代码行数:4,代码来源:product.php

示例3:

            <div id="contact-area">
                <div class="container">
                    <div class="order-form">

						<?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
						

						
						<?php 
echo $form->field($model, 'username')->textInput(['value' => Yii::$app->user->identity->username]);
?>

						<?php 
echo $form->field($model, 'product_id')->dropDownlist(ArrayHelper::map(product::find()->all(), 'id', 'name'), ['prompt' => 'Select product']);
?>
						 <?php 
echo $form->field($model, 'qty')->textInput(['maxlength' => 45]);
?>
 
						 
						
						 <?php 
echo $form->field($model, 'specification')->textArea();
?>
   
						
						<?php 
echo $form->field($model, 'shippingaddress')->textInput(['maxlength' => 100]);
?>
开发者ID:pdbangibang,项目名称:apc-softdev-gd121mi122-4,代码行数:31,代码来源:_form.php

示例4: deleteChildren

 public function deleteChildren()
 {
     //eDebug($data[0],true);
     //if($id!=null) $this->params['id'] = $id;
     //eDebug($this->params,true);
     $product = new product($this->params['id']);
     //$product = $product->find("first", "previous_id =" . $previous_id);
     //eDebug($product, true);
     if (empty($product->id)) {
         flash('error', gt('There was an error deleting the child products.'));
         expHistory::back();
     }
     $childrenToDelete = $product->find('all', 'parent_id=' . $product->id);
     foreach ($childrenToDelete as $ctd) {
         //fwrite($lfh, "Deleting:" . $ctd->id . "\n");
         $ctd->delete();
     }
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:18,代码来源:storeController.php

示例5: deleteProduct

 public function deleteProduct($id)
 {
     $product = product::find($id);
     $product->delete();
     return Redirect::to('all-products');
 }
开发者ID:nangei,项目名称:wpa8pos,代码行数:6,代码来源:ProductController.php

示例6: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $product = product::find($id);
     return view('products.edit', compact('product', $product));
 }
开发者ID:anmolvarshney1993,项目名称:laravelproject,代码行数:11,代码来源:ProductController.php

示例7: chr

 function status_export()
 {
     global $db;
     //eDebug($this->params);
     //$sql = "SELECT * INTO OUTFILE '" . BASE . "tmp/export.csv' FIELDS TERMINATED BY ','  FROM exponent_product WHERE 1 LIMIT 10";
     //is | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes
     $out = '"id","parent_id","model","warehouse_location","title","vendor","product_status","notes"' . chr(13) . chr(10);
     if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {
         $sql = expSession::get('product_export_query');
         //eDebug($sql);
         //expSession::set('product_export_query','');
         $prods = $db->selectArraysBySql($sql);
         //eDebug($prods);
     } else {
         foreach ($this->params['act-upon'] as $prod) {
             $prods[] = array('id' => $prod);
         }
     }
     $stats = new product_status();
     $stats = $stats->find('all');
     $statuses = array();
     foreach ($stats as $stat) {
         $statuses[$stat->id] = $stat->title;
     }
     eDebug($statuses);
     set_time_limit(0);
     $baseProd = new product();
     //$p = new product($pid['id'], false, false);
     //id | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes
     foreach ($prods as $pid) {
         $except = array('crosssellItem', 'optiongroup', 'childProduct');
         $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, null, true, true, $except, true);
         /*if(count($p->expSimpleNote))
           {
               eDebug($p,true);
           }
           else
           {
               continue;
           }*/
         $out .= $this->outputField($p->id);
         $out .= $this->outputField($p->parent_id);
         $out .= $this->outputField($p->model);
         $out .= $this->outputField($p->warehouse_location);
         $out .= $this->outputField($p->title);
         $out .= $this->outputField($p->company->title);
         $out .= $this->outputField($statuses[$p->product_status_id]);
         $noteString = '';
         foreach ($p->expSimpleNote as $note) {
             $noteString .= "(" . $note->name . " - " . date('M d Y H:i A', $note->created_at) . ") " . $note->body . "||";
         }
         $out .= $this->outputField($noteString, '') . chr(13) . chr(10);
         $cps = $baseProd->find('all', 'parent_id=' . $p->id, null, null, null, true, true, $except, true);
         foreach ($cps as $cp) {
             $out .= $this->outputField($cp->id);
             $out .= $this->outputField($cp->parent_id);
             $out .= $this->outputField($cp->model);
             $out .= $this->outputField($cp->warehouse_location);
             $out .= $this->outputField($cp->title);
             $out .= $this->outputField($cp->company->title);
             $out .= $this->outputField($statuses[$cp->product_status_id]);
             $noteString = '';
             foreach ($cp->expSimpleNote as $note) {
                 $noteString .= "(" . $note->name . " - " . date('M d Y H:i A', $note->created_at) . ") " . $note->body . "||";
             }
             $out .= $this->outputField($noteString, '') . chr(13) . chr(10);
         }
     }
     //eDebug($out,true);
     $outFile = 'tmp/product_export_' . time() . '.csv';
     $outHandle = fopen(BASE . $outFile, 'w');
     fwrite($outHandle, $out);
     fclose($outHandle);
     echo "<br/><br/>Download the file here: <a href='" . PATH_RELATIVE . $outFile . "'>Product Export</a>";
     /*eDebug(BASE . "tmp/export.csv");
       $db->sql($sql);
       eDebug($db->error());*/
     /*OPTIONALLY ENCLOSED BY '" . '"' . 
       "' ESCAPED BY '\\'
       LINES TERMINATED BY '" . '\\n' .
       "' */
 }
开发者ID:notzen,项目名称:exponent-cms,代码行数:82,代码来源:reportController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $product = product::find($id);
     $product->delete();
     //Session::flash('flash_message', 'product successfully deleted!');
     return redirect('product/list');
 }
开发者ID:Aashish000,项目名称:store,代码行数:13,代码来源:ProductController.php


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