本文整理汇总了PHP中Mage_Catalog_Model_Product::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getPrice方法的具体用法?PHP Mage_Catalog_Model_Product::getPrice怎么用?PHP Mage_Catalog_Model_Product::getPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getPrice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormatedPrice
function getFormatedPrice()
{
if ($this->currentlySelectedFit() && ($customPrice = $this->customPrice($this->currentlySelectedFit()))) {
return $customPrice;
}
return parent::getPrice();
}
示例2: isPriceSpecial
public function isPriceSpecial(Mage_Catalog_Model_Product $product)
{
/*
* Check if sale price is activated and if so if sale price is LESS than normal price
* I.E., customer might be a Member, so the member price might be less than sale price
*/
$originalPrice = $product->getPrice();
$finalPrice = $product->getFinalPrice();
if ($finalPrice < $originalPrice) {
return self::SPECIAL_PRICE;
}
/*
* check if product is new
*/
$current_date = time();
// compare date
$from_date = $product->getData('news_from_date');
// begin date
$to_date = $product->getData('news_to_date');
// end date
if ($this->isDateBetween($current_date, $from_date, $to_date)) {
return self::NEW_PRODUCT;
}
return false;
}
示例3: _applyOptionsPrice
/**
* Apply gift card amount to price
*
* @param Mage_Catalog_Model_Product $product
* @param int $qty
* @param double $finalPrice
* @return double
*/
protected function _applyOptionsPrice($product, $qty, $finalPrice)
{
if ($product->getCustomOption('card_amount') && $product->getPrice() == 0) {
$amount = $product->getCustomOption('card_amount')->getValue();
$finalPrice += $amount;
}
return $finalPrice;
}
示例4: _applyOptionsPrice
/**
* Apply gift card amount to price
*
* @param Mage_Catalog_Model_Product $product
* @param int $qty
* @param double $finalPrice
* @return double
*/
protected function _applyOptionsPrice($product, $qty, $finalPrice)
{
if ($product->getCustomOption('card_amount') && $product->getPrice() == 0) {
$amount = Mage::helper('directory')->currencyConvert($product->getCustomOption('card_amount')->getValue(), Mage::app()->getStore()->getCurrentCurrencyCode(), Mage::app()->getStore()->getBaseCurrency());
//$amount = $product->getCustomOption('card_amount')->getValue();
$finalPrice += $amount;
}
return $finalPrice;
}
示例5: getRegularPrice
/**
* Get product regular price for rendering on frontend
*
* @param Mage_Catalog_Model_Product $product
* @return int
*/
public function getRegularPrice($product)
{
$price = $product->getPrice();
if ($msrp = $product->getSimpleMsrp()) {
if ($msrp > $price) {
$price = $msrp;
}
}
return $price;
}
示例6: getCatalogRegularPrice
/**
* Tries calculate price without discount; if can't returns null
* @param $product
* @param $store
*/
public function getCatalogRegularPrice(Mage_Catalog_Model_Product $product, $store = null)
{
switch ($product->getTypeId()) {
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
case 'giftcard':
return null;
default:
return $product->getPrice();
}
}
示例7: getBasePrice
/**
* If tier price exist, return it, instead of base price.
*
* @param Mage_Catalog_Model_Product $product
* @param float|null $qty
*
* @return float
*/
public function getBasePrice($product, $qty = null)
{
$price = (double) $product->getPrice();
$tierPrice = $this->_applyTierPrice($product, $qty, $price);
if ($product->getSpecialPrice() && $product->getSpecialPrice() < $price && $qty == 1) {
return $product->getSpecialPrice();
} else {
if ($tierPrice) {
return $tierPrice;
}
}
return min($this->_applyGroupPrice($product, $price), $this->_applyTierPrice($product, $qty, $price), $this->_applySpecialPrice($product, $price));
}
示例8: setPriceFromChild
/**
* @param Mage_Catalog_Model_Product $child
* @return $this
* @throws InvalidArgumentException
*/
public function setPriceFromChild(Mage_Catalog_Model_Product $child)
{
if ($child === null) {
throw new InvalidArgumentException("Product passed is a non-object");
}
$price = $child->getPrice();
$specialPrice = $child->getSpecialPrice();
$specialFrom = $child->getSpecialFromDate();
$specialTo = $child->getSpecialToDate();
$this->setPrice($price, $specialPrice, $specialFrom, $specialTo);
$this->_priceChild = $child;
return $this;
}
示例9: getFinalPrice
/**
* Retrieve product final price
*
* @param integer $qty
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getFinalPrice($qty = null, $product)
{
$finalPrice = $product->getPrice();
if ($product->hasCustomOptions()) {
$customOption = $product->getCustomOption('giftcard_amount');
if ($customOption) {
$finalPrice += $customOption->getValue();
}
}
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$product->setData('final_price', $finalPrice);
return max(0, $product->getData('final_price'));
}
示例10: getFinalPrice
/**
* Get product final price
*
* @param double $qty
* @param Mage_Catalog_Model_Product $product
* @return double
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = $product->getPrice();
$finalPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$product->setFinalPrice($finalPrice);
AO::dispatchEvent('catalog_product_get_final_price', array('product' => $product));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
return max(0, $finalPrice);
}
示例11: getProductData
/**
* Create Product array from Mage_Catalog_Model_Product
*
* @param Mage_Catalog_Model_Product $product
* @return array
*/
public function getProductData(Mage_Catalog_Model_Product $product)
{
try {
$data = array('url' => $product->getProductUrl(), 'title' => htmlspecialchars($product->getName()), 'spider' => 1, 'price' => $product->getPrice(), 'description' => urlencode($product->getDescription()), 'tags' => htmlspecialchars($product->getMetaKeyword()), 'images' => array(), 'vars' => array('sku' => $product->getSku(), 'storeId' => '', 'typeId' => $product->getTypeId(), 'status' => $product->getStatus(), 'categoryId' => $product->getCategoryId(), 'categoryIds' => $product->getCategoryIds(), 'websiteIds' => $product->getWebsiteIds(), 'storeIds' => $product->getStoreIds(), 'groupPrice' => $product->getGroupPrice(), 'formatedPrice' => $product->getFormatedPrice(), 'calculatedFinalPrice' => $product->getCalculatedFinalPrice(), 'minimalPrice' => $product->getMinimalPrice(), 'specialPrice' => $product->getSpecialPrice(), 'specialFromDate' => $product->getSpecialFromDate(), 'specialToDate' => $product->getSpecialToDate(), 'relatedProductIds' => $product->getRelatedProductIds(), 'upSellProductIds' => $product->getUpSellProductIds(), 'getCrossSellProductIds' => $product->getCrossSellProductIds(), 'isSuperGroup' => $product->isSuperGroup(), 'isGrouped' => $product->isGrouped(), 'isConfigurable' => $product->isConfigurable(), 'isSuper' => $product->isSuper(), 'isSalable' => $product->isSalable(), 'isAvailable' => $product->isAvailable(), 'isVirtual' => $product->isVirtual(), 'isRecurring' => $product->isRecurring(), 'isInStock' => $product->isInStock(), 'weight' => $product->getSku()));
// Add product images
if (self::validateProductImage($product->getImage())) {
$data['images']['full'] = array("url" => $product->getImageUrl());
}
if (self::validateProductImage($product->getSmallImage())) {
$data['images']['smallImage'] = array("url" => $product->getSmallImageUrl($width = 88, $height = 77));
}
if (self::validateProductImage($product->getThumbnail())) {
$data['images']['thumb'] = array("url" => $product->getThumbnailUrl($width = 75, $height = 75));
}
return $data;
return $data;
} catch (Exception $e) {
Mage::logException($e);
}
}
示例12: _prepareProductForResponse
/**
* Add special fields to product get response
*
* @param Mage_Catalog_Model_Product $product
*/
protected function _prepareProductForResponse(Mage_Catalog_Model_Product $product)
{
/** @var $productHelper Mage_Catalog_Helper_Product */
$productHelper = Mage::helper('catalog/product');
$productData = $product->getData();
$product->setWebsiteId($this->_getStore()->getWebsiteId());
// customer group is required in product for correct prices calculation
$product->setCustomerGroupId($this->_getCustomerGroupId());
// calculate prices
$finalPrice = $product->getFinalPrice();
$productData['regular_price_with_tax'] = $this->_applyTaxToPrice($product->getPrice(), true);
$productData['regular_price_without_tax'] = $this->_applyTaxToPrice($product->getPrice(), false);
$productData['final_price_with_tax'] = $this->_applyTaxToPrice($finalPrice, true);
$productData['final_price_without_tax'] = $this->_applyTaxToPrice($finalPrice, false);
$productData['is_saleable'] = $product->getIsSalable();
$productData['image_url'] = (string) Mage::helper('catalog/image')->init($product, 'image');
if ($this->getActionType() == self::ACTION_TYPE_ENTITY) {
// define URLs
$productData['url'] = $productHelper->getProductUrl($product->getId());
/** @var $cartHelper Mage_Checkout_Helper_Cart */
$cartHelper = Mage::helper('checkout/cart');
$productData['buy_now_url'] = $cartHelper->getAddUrl($product);
/** @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
$stockItem = $product->getStockItem();
if (!$stockItem) {
$stockItem = Mage::getModel('cataloginventory/stock_item');
$stockItem->loadByProduct($product);
}
$productData['is_in_stock'] = $stockItem->getIsInStock();
/** @var $reviewModel Mage_Review_Model_Review */
$reviewModel = Mage::getModel('review/review');
$productData['total_reviews_count'] = $reviewModel->getTotalReviews($product->getId(), true, $this->_getStore()->getId());
$productData['tier_price'] = $this->_getTierPrices();
$productData['has_custom_options'] = count($product->getOptions()) > 0;
} else {
// remove tier price from response
$product->unsetData('tier_price');
unset($productData['tier_price']);
}
$product->addData($productData);
}
示例13: getProductEntity
public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
{
$result = array();
$result['entity_id'] = $product->getEntityId();
$result['sku'] = $product->getSku();
$result['name'] = $product->getName();
$result['price'] = $product->getPrice();
$result['special_price'] = $product->getSpecialPrice();
$result['special_from_date'] = $product->getSpecialFromDate();
$result['special_to_date'] = $product->getSpecialToDate();
$result['cost'] = $product->getCost();
$result['description'] = $product->getDescription();
$result['short_description'] = $product->getShortDescription();
$result['weight'] = $product->getWeight();
if ($product->isVisibleInSiteVisibility()) {
$result['url_path'] = $this->_getProductUrlWithCache($product);
}
$parentProduct = $this->_getParentProduct($product);
if ($parentProduct != null) {
$result['parent_id'] = $parentProduct->getEntityId();
$result['parent_sku'] = $parentProduct->getSku();
if (!$product->isVisibleInSiteVisibility()) {
$result['name'] = $parentProduct->getName();
if ($parentProduct->isVisibleInSiteVisibility()) {
$result['url_path'] = $this->_getProductUrlWithCache($parentProduct);
}
}
if ($includeExtras && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId()) {
$result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
$attributes = $parentProduct->getTypeInstance(true)->getUsedProductAttributes($parentProduct);
$freshProduct = null;
foreach ($attributes as $attribute) {
if (!array_key_exists('configurable_attributes', $result)) {
$result['configurable_attributes'] = array();
}
$attr = array();
$attr['attribute_name'] = $attribute->getFrontend()->getLabel();
$attr['value'] = $product->getAttributeText($attribute->getAttributeCode());
if (empty($attr['value'])) {
// use the EAV tables only if the flat table doesn't work
if ($freshProduct == null) {
$freshProduct = Mage::getModel('catalog/product')->load($product->getEntityId());
}
$attr['value'] = $attribute->getFrontend()->getValue($freshProduct);
}
$result['configurable_attributes'][] = $attr;
}
}
}
if (!isset($result['purchasable'])) {
$result['purchasable'] = $this->_isPurchasable($product);
}
$images = $this->_getProductImages($product);
if (isset($images['image'])) {
$result['image'] = $images['image'];
}
if (isset($images['small_image'])) {
$result['small_image'] = $images['small_image'];
}
if (isset($images['thumbnail'])) {
$result['thumbnail'] = $images['thumbnail'];
}
if ($includeExtras) {
// Metas
$metas = $this->_getMetas($storeId, $product, $parentProduct);
if ($metas != null) {
//if(isset($metas['meta1'])) $result['meta1'] = $metas['meta1'];
//if(isset($metas['meta2'])) $result['meta2'] = $metas['meta2'];
//if(isset($metas['meta3'])) $result['meta3'] = $metas['meta3'];
//if(isset($metas['meta4'])) $result['meta4'] = $metas['meta4'];
if (isset($metas['meta5'])) {
$result['meta5'] = $metas['meta5'];
}
}
//Custom For ST Bernard Sports
// Set IsNew Flag if product is less then 45 days old.
$result['meta4'] = strtotime($product->getCreatedAt()) + 45 * 24 * 60 * 60 < time() ? "False" : "True";
// Brand and Category
$brandAndCategoryProduct = !$parentProduct || $product->isVisibleInSiteVisibility() ? $product : $parentProduct;
$setSettings = $this->_getProductAttributeSetSettings($brandAndCategoryProduct);
if ($setSettings['brandAttribute'] != null) {
$result['brand'] = $brandAndCategoryProduct->getAttributeText($setSettings['brandAttribute']);
}
if ($setSettings['catFromMagento']) {
$cats = $this->_getCategoryInformation($storeId, $brandAndCategoryProduct);
if (isset($cats['category'])) {
$result['category'] = $cats['category'];
}
if (isset($cats['sub_category'])) {
$result['sub_category'] = $cats['sub_category'];
}
//Custom For ST Bernard Sports
if (isset($cats['third_category'])) {
$result['meta3'] = $cats['third_category'];
}
} else {
if ($setSettings['catFromAttributes']) {
if ($setSettings['categoryAttribute'] != null) {
$result['category'] = $brandAndCategoryProduct->getAttributeText($setSettings['categoryAttribute']);
}
//.........这里部分代码省略.........
示例14: getSelectionPrice
/**
* Calculate price of selection
*
* @param Mage_Catalog_Model_Product $bundleProduct
* @param Mage_Catalog_Model_Product $selectionProduct
* @param decimal $selectionQty
* @return decimal
*/
public function getSelectionPrice($bundleProduct, $selectionProduct, $selectionQty = null, $multiplyQty = true)
{
if (is_null($selectionQty)) {
$selectionQty = $selectionProduct->getSelectionQty();
}
if ($bundleProduct->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
if ($multiplyQty) {
return $selectionProduct->getFinalPrice($selectionQty) * $selectionQty;
} else {
return $selectionProduct->getFinalPrice($selectionQty);
}
} else {
if ($selectionProduct->getSelectionPriceType()) {
// percent
return $bundleProduct->getPrice() * ($selectionProduct->getSelectionPriceValue() / 100) * $selectionQty;
} else {
// fixed
return $selectionProduct->getSelectionPriceValue() * $selectionQty;
}
}
}
示例15: getPrice
/**
* Retrieve product price
*
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getPrice($product)
{
return $product->getPrice();
}