本文整理汇总了PHP中Product类的典型用法代码示例。如果您正苦于以下问题:PHP Product类的具体用法?PHP Product怎么用?PHP Product使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Product类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setProduct
/**
* The setter of the field product_id.
* @param Product $product - the product related to the issue
*/
public function setProduct(Product $product)
{
if ($product == NULL) {
throw new InvalidArgumentException('[Model\\Issue] Invalid Model\\Product.');
}
$this->product_id = $product->getProductId();
}
示例2: productMultiDialog
function productMultiDialog($productId = 0)
{
$chooseProduct = new Product($productId);
$product = new Product();
$dis['searchKey'] = "";
$dis['searchProductCat'] = "";
$dis['searchProductCatId'] = "";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$searchKey = $this->input->post('searchName');
$searchProductCat = $this->input->post('searchProductCat');
$searchProductCatId = $this->input->post('searchProductCatId');
$product->like("name", $searchKey);
if ($searchProductCatId != "") {
$product->where_related_productcat('id', $searchProductCatId);
}
$dis['searchKey'] = $searchKey;
$dis['searchProductCat'] = $searchProductCat;
$dis['searchProductCatId'] = $searchProductCatId;
$dis['isSearch'] = true;
}
if ($productId != 0 && $chooseProduct->accessory->result_count() > 0) {
$product->where_not_in('id', $chooseProduct->accessory);
}
$product->order_by("name", "asc");
$product->get_iterated(100);
$dis['chooseProduct'] = $chooseProduct;
$dis['base_url'] = base_url();
$dis['product'] = $product;
$this->load->view("admin/layout/dialogContent/productMultiSelectDialogContent", $dis);
}
示例3: __construct
public function __construct($controller, $name)
{
$product = new Product();
$title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
$urlSegment = new TextField('URLSegment', 'URL Segment');
$menuTitle = new TextField('MenuTitle', 'Navigation Title');
$sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
$categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
$otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
$model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
$featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
$allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
$price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
$image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
$content = new HtmlEditorField('Content', 'Content');
$fields = new FieldList();
$fields->add($title);
//$fields->add($urlSegment);
//$fields->add($menuTitle);
//$fields->add($sku);
$fields->add($categories);
//$fields->add($otherCategories);
$fields->add($model);
$fields->add($featured);
$fields->add($allow_purchase);
$fields->add($price);
$fields->add($image);
$fields->add($content);
//$fields = $product->getFrontEndFields();
$actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
$requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
parent::__construct($controller, $name, $fields, $actions, $requiredFields);
}
示例4: setProduct
public function setProduct(Product $product)
{
if ($product) {
$this->api()->addProduct($product->get());
}
return $this;
}
示例5: getProductGroupsFilter
private static function getProductGroupsFilter(Product $product)
{
$filter = new ARSelectFilter();
$filter->setOrder(new ARFieldHandle(__CLASS__, "position"), 'ASC');
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, "productID"), $product->getID()));
return $filter;
}
示例6: run
public function run()
{
if (!$this->product) {
return;
}
$this->render($this->view, ['dataProvider' => $this->product->getLinkedProductsDataProvider($this->code)]);
}
示例7: testAdd
/**
* @covers QueueController::Add
* @todo Implement testAdd().
*/
public function testAdd()
{
$person = Person::factory('adult');
$person->name = 'Poehavshiy';
$person->add();
$store = Store::factory('Grocery');
$store->name = 'Prison';
$store->add();
$product = new Product();
$product->name = 'Sladkiy hleb';
$product->add();
$request = Application::getInstance()->request;
$request->setParams(array('storeId' => $store->id, 'personId' => $person->id, 'product_' . $product->id => 'on'));
$personId = $request->p('personId');
$storeId = $request->p('storeId');
$store = Store::get($storeId);
$person = Person::get($personId);
$store->queue->add($person);
$person->basket->drop();
$name = 'product_' . $product->id;
$value = $product;
if (preg_match_all('/^product_(\\d+)$/', $name, $matches)) {
$person->basket->add(Product::get($matches[1][0]));
}
}
示例8: getAdminInterface
public function getAdminInterface()
{
$st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name";
$products = Database::singleton()->query_fetch_all($st);
$formPath = "/admin/EComm§ion=Plugins&page=ChangeProductPrice";
$form = new Form('change_product_prices', 'post', $formPath);
if ($form->validate() && isset($_REQUEST['submit'])) {
foreach ($products as $product) {
$ECommProduct = new Product($product['product_id']);
$ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]);
$ECommProduct->save();
}
return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>";
}
$oldSupplier = 0;
$currentSupplier = 0;
$defaultValue = array();
foreach ($products as $product) {
$currentSupplier = $product['supplier_id'];
if ($oldSupplier != $currentSupplier) {
$form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>');
}
$form->addElement('text', 'product_' . $product['product_id'], $product['product_name']);
$defaultValue['product_' . $product['product_id']] = $product['product_price'];
$oldSupplier = $product['supplier_id'];
}
$form->addElement('submit', 'submit', 'Submit');
$form->setDefaults($defaultValue);
return $form->display();
}
示例9: dataAction
public function dataAction()
{
$w = 80;
$h = 100;
$img = $this->_getParam('img');
$ar_img = split('\\.', $img);
//print_r($ar_img);exit;
$Product = new Product();
$product = $Product->get($ar_img[0]);
if ($product && $product['picture']) {
$res = GetWebPage($product['picture'], $RetStatus);
//header('Content-type: image/jpg');
//print_r($res);exit;
//$ar = getimagesizefromstring($res);
$im = imagecreatefromstring($res);
$width = imagesx($im);
$height = imagesy($im);
//print_r($width." ".$height);
if ($width > $height) {
$new_height = $w * $height / $width;
$new_width = $w;
} else {
$new_height = $h;
$new_width = $h * $width / $height;
}
$im_new = imagecreatetruecolor($new_width, $new_height);
//imagecopyresized($im_new,$im,0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagecopyresampled($im_new, $im, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
header('Content-type: image/jpg');
imagejpeg($im_new);
}
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
}
示例10: run
public function run()
{
$this->init();
$this->preProcess();
global $cookie, $link;
$id_product = Tools::getValue('id');
$product = new Product($id_product, true, 1);
$id_customer = (isset(self::$cookie->id_customer) and self::$cookie->id_customer) ? (int) self::$cookie->id_customer : 0;
if ($id_customer) {
$sql = "select id from ps_wishlist where id_customer = " . $id_customer . " and id_product = " . $product->id;
$res = Db::getInstance()->ExecuteS($sql);
if ($res) {
self::$smarty->assign("in_wishlist", true);
} else {
self::$smarty->assign("in_wishlist", false);
}
} else {
self::$smarty->assign("in_wishlist", false);
}
$idImage = $product->getCoverWs();
if ($idImage) {
$idImage = $productObj->id . '-' . $idImage;
} else {
$idImage = Language::getIsoById(1) . '-default';
}
$image_link = $link->getImageLink($productObj->link_rewrite, $idImage, 'thickbox');
self::$smarty->assign('product', $product);
self::$smarty->assign('imagelink', $image_link);
self::$smarty->assign('productlink', $product->getLink());
die(self::$smarty->display(_PS_THEME_DIR_ . 'quick-view.tpl'));
}
示例11: log
/**
* Save log message
*
* @param int $action
* @param Product $product
* @param int $type
* @param string $message
* @param null|string $code
* @return int|false
*/
protected static function log($action, Product $product, $type, $message, $code = null)
{
$message = trim($message);
$template = $product->getTemplate();
$data = array('product_id' => $product->id, 'template_id' => $product->template_id, 'product_name' => $product->original_title, 'template_name' => $template ? $template->name : '-', 'message' => $message, 'code' => $code, 'action' => $action, 'type' => $type, 'datetime' => time());
return db_query('INSERT INTO ?:ebay_product_log ?e', $data);
}
示例12: create
public static function create(Customer $cus, Product $prd, $opts)
{
$material = $opts['material'];
$order_sn = self::makeOrderSn();
Pdb::insert(array_merge($opts, array('order_no' => $order_sn, 'customer' => $cus->id, 'product' => $prd->id, 'state' => 'InCart', 'estimate_price' => $prd->estimatePrice(compact('material')), 'add_cart_time=NOW()' => null)), self::$table);
return new self(Pdb::lastInsertId());
}
示例13: create
/**
* Creates a scheduling in the database.
*
* @return Response
*/
public function create()
{
$request = $this->request;
$scheduling = new Product();
$scheduling->assign(['end_period' => $request->get('end_period', 'string'), 'period_type_id' => $request->get('period_type_id', 'strint')]);
return $this->response($request, $scheduling, true);
}
示例14: search
function search()
{
$viewMode = $this->uri->segment(2, "") == "" ? "ma-tran" : $this->uri->segment(2);
$orderBy = $this->uri->segment(3, "") == "" ? "moi-nhat" : $this->uri->segment(3);
$page = $this->uri->segment(4, "") == "" ? "trang-1" : $this->uri->segment(4);
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$searchKey = $this->input->post('searchKey');
$this->session->set_userdata('searchKey', $searchKey);
}
$searchKey = $this->session->userdata('searchkey');
$limit = $viewMode == "ma-tran" ? 15 : 10;
$offset = ($this->getPageNumber($page) - 1) * $limit;
$product = new Product();
if (trim($searchKey) != "") {
$product->like('name', $searchKey);
}
$product->where('active', 1);
$product->order_by($this->getOrderBy($orderBy), $this->getOrderDirection($orderBy));
$product->get_paged_iterated();
$dis['product'] = $product;
$dis['pageUrl'] = "tim-kiem";
$config['base_url'] = site_url($url . "/" . $viewMode . "/" . $orderBy . "/trang-");
$config['total_rows'] = $product->paged->total_rows;
$config['per_page'] = $limit;
$config['use_page_numbers'] = TRUE;
$config['uri_segment'] = 4;
$config['num_links'] = 3;
$config['full_tag_open'] = '<span class="pagin">';
$config['full_tag_close'] = "</span>";
$config['first_link'] = FALSE;
$config['first_tag_open'] = '';
$config['first_tag_close'] = '';
$config['last_link'] = FALSE;
$config['last_tag_open'] = '';
$config['last_tag_close'] = '';
$config['next_link'] = '<img src="' . base_url() . 'images/pagination_next.png" />';
$config['next_tag_open'] = '';
$config['next_tag_close'] = '';
$config['prev_link'] = '<img src="' . base_url() . 'images/pagination_pre.png" /';
$config['prev_tag_open'] = '';
$config['prev_tag_close'] = '';
$config['num_tag_open'] = '';
$config['num_tag_close'] = '';
$config['cur_tag_open'] = '<span class="active">';
$config['cur_tag_close'] = '</span>';
$this->pagination->initialize($config);
if ($viewMode == 'ma-tran') {
$dis['view'] = 'product/product_grid';
} else {
$dis['view'] = 'product/product_list';
}
$productSaleOff = new product();
$productSaleOff->where('active', 1);
$productSaleOff->where('isSale', 1);
$productSaleOff->order_by('id', 'desc');
$productSaleOff->get_iterated(15);
$dis['productSaleOff'] = $productSaleOff;
$dis['base_url'] = base_url();
$this->viewfront($dis);
}
示例15: indexAction
public function indexAction()
{
$categories = new Category();
//$this->view->categories = array ('1','2','3','4');
//$this->view->categories = $categories->fetchAll();
//$this->_helper->actionStack('detail-list');
//$this->_forward('detail-list');
//$this->rrr();
$front = Zend_Controller_Front::getInstance();
if ($front->getRequest()->getParam('controller') == 'toy') {
$toy_id = $front->getRequest()->getParam('toy_id');
$Product = new Product();
$toy = $Product->get($toy_id);
$cat_id = $toy['categoryId'];
$this->view->current_id = $cat_id;
$this->view->p_type = 'toy';
} else {
$cat_id = $front->getRequest()->getParam('cat_id');
$cat_id = $cat_id ? $cat_id : 0;
$this->view->current_id = $cat_id;
$this->view->p_type = 'category';
}
//print_r($cat_id);exit;
$this->view->categories = $categories->get_sort_categories($cat_id);
}