本文整理汇总了PHP中Product::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getId方法的具体用法?PHP Product::getId怎么用?PHP Product::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProduct
/**
* A kosárhoz hozzá adja a terméket hozzá tartozó mennyiséggel együtt.
* A products arrayben a termék id-je az index
* és ugyan ezzel indexelem a qauntities tömböt, így te megoldásod is maradhat és egyértelmű.
*
* @param Product $product
* @param int $quantity
*/
public function addProduct($product, $quantity)
{
if (!isset($this->products[$product->getId()])) {
$this->products[$product->getId()] = $product;
$this->quantities[$product->getId()] = $quantity;
} else {
$this->quantities[$product->getId()] += $quantity;
}
//echo "elemek száma: " . count($this->items) . " db & " . count($this->quantity) . " db.<br>";
}
示例2: transform
/**
* Transforms an object (product) to a int (id).
*
* @param Product|null $entity
* @return string
*/
public function transform($entity)
{
if (null === $entity) {
return "";
}
return $entity->getId();
}
示例3: compute
function compute(Product $product)
{
$discountProvider = DiscountProvider::getInstance();
$discountAsPercent = $discountProvider->getDiscountFor($product->getId());
$price = $product->getPrice();
$discountAsValue = $price * $discountAsPercent / 100;
return $price - $discountAsValue;
}
示例4: test_initialization
public function test_initialization()
{
$product = new Product();
$this->assertEqual($product->getId(), 0);
$this->assertEqual($product->getName(), '');
$this->assertEqual($product->getCreated(), '');
$this->assertEqual($product->getUpdated(), '');
}
示例5: editProduct
public function editProduct(Product $product)
{
$editStmt = $this->db->prepare("UPDATE\n products\n SET\n name = ?, model = ?, price = ?, quantity = ?, category_id = ?\n WHERE id = ?")->execute([$product->getProductname(), $product->getProductmodel(), $product->getProductprice(), $product->getProductquantity(), $product->getCategory(), $product->getId()]);
if ($editStmt->getAffectedRows() > 0) {
return true;
}
return false;
}
示例6: getId
public function getId()
{
if ($this->__isInitialized__ === false) {
return (int) $this->_identifier["id"];
}
$this->__load();
return parent::getId();
}
示例7: ensureConsistency
/**
* Checks and repairs the internal consistency of the object.
*
* This method is executed after an already-instantiated object is re-hydrated
* from the database. It exists to check any foreign keys to make sure that
* the objects related to the current object are correct based on foreign key.
*
* You can override this method in the stub class, but you should always invoke
* the base method from the overridden method (i.e. parent::ensureConsistency()),
* in case your model changes.
*
* @throws PropelException
*/
public function ensureConsistency()
{
if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
$this->aProduct = null;
}
if ($this->aGoogleshoppingAccount !== null && $this->googleshopping_account_id !== $this->aGoogleshoppingAccount->getId()) {
$this->aGoogleshoppingAccount = null;
}
}
示例8: loadImgbyProduct
public static function loadImgbyProduct(Product $product)
{
$m = $product->getId();
$sql = "SELECT * FROM images where product_id = '{$m}'";
$re = self::$db->query($sql);
if ($re) {
return $re['link'];
}
}
示例9: ensureConsistency
/**
* Checks and repairs the internal consistency of the object.
*
* This method is executed after an already-instantiated object is re-hydrated
* from the database. It exists to check any foreign keys to make sure that
* the objects related to the current object are correct based on foreign key.
*
* You can override this method in the stub class, but you should always invoke
* the base method from the overridden method (i.e. parent::ensureConsistency()),
* in case your model changes.
*
* @throws PropelException
*/
public function ensureConsistency()
{
if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
$this->aProduct = null;
}
if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) {
$this->aAttributeAv = null;
}
}
示例10: create
public static function create(Product $oProduct)
{
$oCartProduct = new CartProduct();
$oCartProduct->setImage($oProduct->getImage());
$oCartProduct->setId($oProduct->getId());
$oCartProduct->setDescription($oProduct->getDescription());
$oCartProduct->setName($oProduct->getName());
$oCartProduct->setPrice($oProduct->getPrice());
return $oCartProduct;
}
示例11: getObjectForProductAndParameter
public function getObjectForProductAndParameter(Product $product, $param)
{
$q = $this->createQuery('c')->from('ParameterProductValue ppv')->where('ppv.Parameter.id = ? ', $param->getId())->addWhere('ppv.Product.id = ?', $product->getId());
$ppv = $q->fetchOne();
if (!$ppv) {
$ppv = new ParameterProductValue();
$ppv->setProduct($product);
$ppv->setParameter($param);
$ppv->setCommonValue('empty');
$ppv->save();
}
return $ppv;
}
示例12: setOrder
public function setOrder(Product $product)
{
$id_product = $product->getId();
$query = "SELECT * FROM basket WHERE id_product =" . $id_product;
$res = $this->db->query($query);
if ($res) {
$basket = $res->fetchAll();
$id_order = $basket[count($basket) - 1]['id_order'];
$query = "SELECT * FROM order WHERE id =" . $id_order . " AND status =" . STATUS_PAID;
$res = $this->db->query($query);
if ($res && ($order = $res->fetchObject("Order", array($this->db)))) {
$this->order = $order;
$this->id_order = $order->getId();
return true;
} else {
throw new Exception("Only buyers can leave a comment");
}
} else {
throw new Exception("Only buyers can leave a comment");
}
}
示例13: pushProduct
/**
* Adds product into the pool
*
* @param Product $product
* @return void
*/
public static function pushProduct(Product $product)
{
self::$products[$product->getId()] = $product;
}
示例14: getPreferredLocations
/**
* Getting all the preferred locations
*
* @param Product $product
* @param PreferredLocationType $type
* @param string $activeOnly
* @param string $pageNo
* @param unknown $pageSize
* @param unknown $orderBy
* @param unknown $stats
* @return Ambigous <Ambigous, multitype:, multitype:BaseEntityAbstract >
*/
public static function getPreferredLocations(Product $product, PreferredLocationType $type = null, $activeOnly = true, $pageNo = null, $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE, $orderBy = array(), &$stats = array())
{
$where = array('productId = ? ');
$params = array($product->getId());
if ($type instanceof PreferredLocationType) {
$where[] = 'typeId = ?';
$params[] = $type->getId();
}
return self::getAllByCriteria(implode(' AND ', $where), $params, $activeOnly, $pageNo, $pageSize, $orderBy, $stats);
}
示例15: assertPreConditions
/**
* {@inheritdoc}
*/
protected function assertPreConditions()
{
$this->assertInstanceOf('JLM\\ProductBundle\\Model\\ProductCategoryInterface', $this->entity);
$this->assertNull($this->entity->getId());
}