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


PHP Product::search方法代码示例

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


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

示例1: index

 public function index()
 {
     // Check if user has sent a search query
     if ($query = Input::get('query', false)) {
         // Use the Elasticquent search method to search ElasticSearch
         $products = Product::search($query);
     } else {
         // Show all posts if no query is set
         $products = Product::all();
     }
     return View::make('products', compact('products'));
 }
开发者ID:eavillacis,项目名称:example_elasticsearch,代码行数:12,代码来源:ProductsController.php

示例2: actionLocation

 public function actionLocation()
 {
     $cat = Yii::app()->getRequest()->getQuery('cat');
     $bname = Yii::app()->getRequest()->getQuery('keyword');
     $catname = Category::model()->getCategoryName($cat);
     if ($cat == 'all' || empty($catname)) {
         $query = "SELECT *  \n\t\t\t\t\t\tFROM  `mm_product` \n\t\t\t\t\t\tWHERE  `product_name` LIKE  '" . $bname . "%' \n\t\t\t\t\t\tORDER BY `product_name` LIMIT 10";
     } else {
         $query = "SELECT *  \n\t\t\t\t\tFROM  `mm_product` \n\t\t\t\t\tWHERE  `product_name` LIKE  '%" . $bname . "%'\n\t\t\t\t\tAND\t`product_category_id` IN (SELECT entity_id FROM category WHERE  category_name LIKE '" . $catname . "')";
     }
     $command = Yii::app()->db->createCommand($query);
     $result = $command->queryAll();
     $model = new Product('search');
     $model->unsetAttributes();
     // clear any
     $model->product_name = $bname;
     $model->product_category = $catname;
     //send model object for search
     $this->render('index', array('dataProvider' => $model->search(), 'model' => $model));
     /*
     		$dataProvider=new CArrayDataProvider($result, array(
     					'sort'=>false,
     					'keyField'=>'id', //this is what will be considered your key field
     					'pagination'=>array(
     					'pageSize'=>30, //eureka! you can configure your pagination from here
                     ),
     				
                 ));
     
     		//echo '<pre>'; var_dump($pp); die();
     	
     		$this->render('index',array(
     			'dataProvider'=>$dataProvider,
     		));*/
     //throw new CHttpException(404,'The requested page does not exist.');
 }
开发者ID:indresh90,项目名称:utopeen_webpeoduct,代码行数:36,代码来源:SearchController2.php

示例3: Database

include_once "../config/core.php";
// check if logged in as admin
include_once "login_checker.php";
// include classes
include_once '../config/database.php';
include_once '../objects/product.php';
include_once '../objects/product_image.php';
include_once '../objects/product_pdf.php';
include_once '../objects/category.php';
// get database connection
$database = new Database();
$db = $database->getConnection();
// initialize objects
$product = new Product($db);
$product_image = new ProductImage($db);
$product_pdf = new ProductPdf($db);
$category = new Category($db);
// get search term
$search_term = isset($_GET['s']) ? $_GET['s'] : '';
// set page title
$page_title = "Product Search Results";
// include page header HTML
include_once "layout_head.php";
// search products
$stmt = $product->search($search_term, $from_record_num, $records_per_page);
// count retrieved products
$num = $stmt->rowCount();
// include products table HTML template
include_once "read_products_template.php";
// include page footer HTML
include_once "layout_foot.php";
开发者ID:marwyre,项目名称:e-commerce,代码行数:31,代码来源:search_products.php

示例4: unset

        $_SESSION['limit'] = 7;
        //���������� ��������� �������� ������ �� ���������
        $limit = $_SESSION['limit'];
    } else {
        $_SESSION['limit'] += 7;
        $limit = $_SESSION['limit'];
    }
} else {
    unset($_SESSION['limit']);
    $_SESSION['limit'] = 7;
    //���������� ��������� �������� ������ �� ���������
    $limit = $_SESSION['limit'];
}
require_once 'class.php';
$obj = new Product();
switch ($_POST["form"]) {
    case 'selectId':
        $result = $obj->selectId($_POST['id'], $_POST['category'], $limit);
        echo json_encode($result);
        break;
    case 'search':
        $result = $obj->search($_POST["id"], $_POST["capacity"], $_POST["frame"], $_POST["price"], $_POST["waterproof"], $_POST['category'], $_POST["weight"], $_POST['sort'], $limit);
        echo json_encode($result);
        break;
    case 'moreInfo':
        $result = $obj->moreInfo($_POST["id"]);
        $result[0]['attr'] = unserialize($result[0]['attr']);
        $result[0]['img'] = unserialize($result[0]['img']);
        echo json_encode($result);
        break;
}
开发者ID:Torredo,项目名称:aliev,代码行数:31,代码来源:data.php

示例5: foreach

             $item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg";
             $html .= "<tr>";
             $html .= "  <td><img src='" . $item->picture . "' height='40' width='40'/></td>";
             $html .= "  <td>storeid " . $item->storeid . "</td>";
             $html .= "  <td><a class='btn btn-primary' href='updatestorepic.php?id=" . $item->id . "'>Update</a></td>";
             $html .= "  <td><button class='btn btn-danger btndelete'>Delete <span hidden>" . $item->id . "</span></button></td>";
             $html .= "</tr>";
         }
         $filename = 0;
         echo $html;
     } else {
         echo "no data";
     }
 } else {
     if ($_GET['itemtype'] == "product") {
         $items = Product::search($input);
         if (count($items) > 0) {
             foreach ($items as $item) {
                 $filename++;
                 $random = rand(0, 1);
                 file_put_contents("images/" . $filename . "x" . $random . ".jpg", base64_decode($item->picture));
                 $item->picture = HOST . "includes/webservices/images/" . $filename . "x" . $random . ".jpg";
                 $html .= "<tr>";
                 $html .= "  <td><img src='" . $item->picture . "' height='40' width='40'/></td>";
                 $html .= "  <td>storeid " . $item->storeid . "</td>";
                 $html .= "  <td>" . $item->name . "</td>";
                 $html .= "  <td>" . $item->description . "</td>";
                 $html .= "  <td><a class='btn btn-primary' href='updateproduct.php?id=" . $item->id . "'>Update</a></td>";
                 $html .= "  <td><button class='btn btn-danger btndelete'>Delete <span hidden>" . $item->id . "</span></button></td>";
                 $html .= "</tr>";
             }
开发者ID:NemOry,项目名称:EpicueWebPanel,代码行数:31,代码来源:gettable.php

示例6: stdClass

 * which is then json encoded and returned as a json file response
 */
$result = new stdClass();
$code = 200;
/**
 * Process the search request
 */
if (isset($_POST['form']) && $_POST['form'] == "search") {
    if (isset($_POST['search_term']) && isset($_POST['search_type'])) {
        $search_term = $_POST['search_term'];
        $search_type = $_POST['search_type'];
        $result = "";
        $filters = $_POST['filters'];
        require_once APPLICATION_PATH . MODEL_DIR . '/Product.php';
        $order = new Product('replicated');
        $result = $order->search($search_term, $filters, $search_type);
    }
} elseif (isset($_POST['form']) && $_POST['form'] == "search_by_sku") {
    require_once APPLICATION_PATH . MODEL_DIR . '/Product.php';
    $result = "";
    $item_sku = $_POST['item_sku'];
    $products = new Product('replicated');
    $result = $products->SearchItemsBySku($item_sku);
} elseif (isset($_POST['form']) && $_POST['form'] == "master_products") {
    require_once APPLICATION_PATH . MODEL_DIR . '/Product.php';
    $result = "";
    $products = new Product('replicated');
    $result = $order->getAllMasterProducts();
    header('Content-Type: application/json');
    echo json_encode(array("result" => $result));
} elseif (isset($_POST['form']) && $_POST['form'] == "get_search_history") {
开发者ID:kameshwariv,项目名称:testexample,代码行数:31,代码来源:searchProducts.php

示例7: substr

<?php

require_once $libpath = substr(str_replace('\\', '/', __DIR__), 0, -29) . 'library/initialize.php';
if (isset($_POST['keyword'])) {
    $keywords = htmlentities($_POST["keyword"]);
    if ($keywords == "" && !isset($_SESSION["user_id"])) {
        redirect_to(HOME);
    } elseif ($keywords == "" && isset($_SESSION["user_id"])) {
        redirect_to(HOME . "all-products");
    }
    $products = Product::search($keywords);
    if ($products == null) {
        // No results found
        $session->message("Sorry could not find the product");
        redirect_to(HOME);
    }
} else {
    // Probably a GET request
    redirect_to(HOME);
}
global $categories;
include $dir_public . 'search.php';
开发者ID:hc-hacker,项目名称:OLX,代码行数:22,代码来源:search.php

示例8:

<?php

// Find all the products
require_once "../../includes/initialize.php";
$str = $_GET['q'];
$products = Product::search($str);
foreach ($products as $product) {
    ?>
        <article class="productInfo"><!-- Each individual product description -->
          <div><img src="../../<?php 
    echo $product->image_path();
    ?>
"/></div>
          <p class="price"><?php 
    echo $product->name;
    ?>
</p>
          <p class="productContent"><?php 
    $cat = Category::find_by_id($product->cat_id);
    echo $cat->get_name();
    ?>
</p>
          <p class="productContent"><?php 
    $user = User::find_by_id($product->userid);
    echo $user->full_name();
    ?>
</p>
		    </article>
<?php 
}
开发者ID:hc-hacker,项目名称:My-OLX,代码行数:30,代码来源:search.php

示例9: Smarty

<?php

require_once 'config/config.conf.php';
try {
    $search = Product::search($_GET);
    //echo Utils::debug($search);
    $smarty = new Smarty();
    $tpl_vars = array('pages' => $pages, 'current_page' => $current_page, 'search' => $search);
    $smarty->assign($tpl_vars);
    $smarty->display('search.tpl');
} catch (Exception $e) {
    exit($e->getMessage());
}
开发者ID:NikosAnderson,项目名称:shop,代码行数:13,代码来源:search.php

示例10: actionIndex

 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $this->layout = "column1";
     $searchModel = new Product('search');
     $dataProvider = new CActiveDataProvider('Product');
     if (isset($_GET['Product'])) {
         $searchModel->attributes = $_GET['Product'];
         $dataProvider = $searchModel->search();
     }
     $this->render('index', array('dataProvider' => $dataProvider, 'searchModel' => $searchModel));
 }
开发者ID:kevindaus,项目名称:Order-Billing-Inventory-System-Marcials-Furniture,代码行数:14,代码来源:ProductController.php

示例11: array

                $products = Product::search($input);
            } else {
                if ($_GET['itemtype'] == "traffic") {
                    $traffics = Traffic::search($input);
                } else {
                    if ($_GET['itemtype'] == "review") {
                        $reviews = Review::search($input);
                    }
                }
            }
        }
    }
} else {
    $users = User::search($input);
    $stores = Store::search($input);
    $products = Product::search($input);
    $traffics = Traffic::search($input);
    $reviews = Review::search($input);
}
$tables = array();
if ($users != null) {
    $table = new Table("users", $users);
    array_push($tables, $table);
}
if ($stores != null) {
    $table = new Table("stores", $stores);
    array_push($tables, $table);
}
if ($products != null) {
    $table = new Table("products", $products);
    array_push($tables, $table);
开发者ID:NemOry,项目名称:EpicueWebPanel,代码行数:31,代码来源:search.php

示例12: collection_product_search

 public function collection_product_search()
 {
     $keywords = !empty($_GET['keywords']) ? $_GET['keywords'] : '';
     $collection_id = $_GET['collection_id'];
     $products = Product::search(array('limit' => 10, 'offset' => 0, 'where' => 'p.title like \'%' . $keywords . '%\' or p.description like \'%' . $keywords . '%\''));
     if ($products) {
         $output = '<ul>';
         foreach ($products as $product) {
             $output .= '<li id="possible-product-' . $product->id . '"><form id="possible-product-' . $product->id . '-form"><input type="hidden" name="ecommerce_product_collection[collection_id]" value="' . $collection_id . '" /><input type="hidden" name="ecommerce_product_collection[product_id]" value="' . $product->id . '" /></form>';
             $output .= '<a href="#" onclick="collection_product_create(' . $product->id . ');return false;">' . $product->title . '</a></li>';
         }
         $output .= '</ul>';
     } else {
         $output = '<p class="normal">No products matched your search.</p>';
     }
     echo $output;
 }
开发者ID:shuhrat,项目名称:frog_ecommerce,代码行数:17,代码来源:EcommerceController.php

示例13: actionList

 /**
  * Displays a particular model's products as a long list.
  * @param str $slug the 'slug' identifier of the model to be displayed
  */
 public function actionList($slug)
 {
     // Retrieve the model via it's slug
     $model_localization = $this->loadLocalizationModelSlug($slug);
     $model = $model_localization->category;
     if (!$model->visible) {
         throw new CHttpException(404, Yii::t('app', 'La page demandée n\'existe pas.'));
     }
     $this->pageTitle = $model_localization->name . " - " . Yii::app()->name;
     $alternatives = array();
     foreach ($model->categoryLocalizations as $localization) {
         $alternatives[$localization->locale_id] = $this->createAbsoluteUrl("view", array("slug" => $localization->slug, "language" => $localization->locale_id));
     }
     $this->alternatives = $alternatives;
     // Generate the subcategories to display in the sidebar.
     // Generate the subcategories to display in the sidebar.
     $children_cache_id = Yii::app()->request->hostInfo . " CategoryController:[children_cats_for_cat] " . $model->id;
     $cache_duration = 300;
     $menu_array = Yii::app()->cache->get($children_cache_id);
     if (!$menu_array) {
         $menu_array = array();
         $children = new Category();
         $children->unsetAttributes();
         $children->visible = 1;
         $children->id = $model->id;
         $category_data_provider = $children->searchChildren();
         foreach ($category_data_provider->getData() as $child) {
             if ($this->isB2b()) {
                 // In a B2B store, we show a list of products so users can select many products at once
                 $menu_array[] = array('label' => $child->categoryLocalization->name, 'url' => array('category/list', "slug" => $child->categoryLocalization->slug));
             } else {
                 $menu_array[] = array('label' => $child->categoryLocalization->name, 'url' => array('category/view', "slug" => $child->categoryLocalization->slug));
             }
         }
         Yii::app()->cache->set($children_cache_id, $menu_array, $cache_duration);
     }
     $this->menu = $menu_array;
     if ($model->parent_category) {
         // This is a subcategory
         // Subcategories must display their products. They must also add their parents categories to the page's breadcrumbs
         // Display breadcrumbs in the right order (home >> root category >> subcategory 1 >> subcatory 2, etc.)
         $this->breadcrumbs = array();
         function appendMotherCatToBreadcrumbs($cat, &$breadarray, $locale)
         {
             $locale_category = CategoryLocalization::model()->find("category_id = :category AND locale_id = :locale", array(":category" => $cat->id, ":locale" => $locale));
             $breadarray[$locale_category->name] = array("category/view", "slug" => $locale_category->slug);
             if ($cat->parent_category) {
                 appendMotherCatToBreadcrumbs($cat->parentCategory, $breadarray, $locale);
             }
         }
         if ($model->parent_category) {
             appendMotherCatToBreadcrumbs($model->parentCategory, $this->breadcrumbs, Yii::app()->language);
             // The array returned is reversed (top category at the end) we need to reverse it.
             $this->breadcrumbs = array_reverse($this->breadcrumbs);
         }
         // We're at the end of the run, just append our name
         $this->breadcrumbs[] = $model_localization->name;
         // Retrieve the order's products (with the correct localization)
         $products_data_provider = null;
         $product = new Product();
         $product->unsetAttributes();
         $product->visible = 1;
         $product->discontinued = 0;
         $product->categoryId = $model->id;
         $product->restrictScopeToCurrentLocale = false;
         if ($model->is_brand) {
             $products_data_provider = $product->searchForBrand($model);
         } else {
             $products_data_provider = $product->search();
         }
         $products_data_provider->setPagination(array('pageSize' => 100));
         $this->render('list', array('model' => $model, 'localization' => $model_localization, 'products' => $products_data_provider));
     } else {
         throw new CHttpException(404, Yii::t('app', 'La page demandée n\'existe pas.'));
     }
 }
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:80,代码来源:CategoryController.php


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