本文整理汇总了PHP中Mage_Catalog_Model_Product::getFinalPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getFinalPrice方法的具体用法?PHP Mage_Catalog_Model_Product::getFinalPrice怎么用?PHP Mage_Catalog_Model_Product::getFinalPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getFinalPrice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFinalPrice
function getFinalPrice($qty = null)
{
if ($this->currentlySelectedFit() && ($customPrice = $this->customPrice($this->currentlySelectedFit()))) {
return $customPrice;
}
return parent::getFinalPrice();
}
示例2: setCategoryPaths
/**
* set category path
*/
public function setCategoryPaths()
{
$result = array();
if ($this->_getExportHelper()->isProductVisibleInCategories($this->item)) {
$itemsOrderOption = Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_ITEM_SORT);
$linkedCategories = Mage::getResourceSingleton('shopgate/product')->getCategoryIdsAndPosition($this->item);
foreach ($linkedCategories as $link) {
$categoryItemObject = new Shopgate_Model_Catalog_CategoryPath();
$categoryItemObject->setUid($link['category_id']);
switch ($itemsOrderOption) {
case Shopgate_Framework_Model_System_Config_Source_Item_Sort::SORT_TYPE_LAST_UPDATED:
$sortIndex = Mage::getModel('core/date')->timestamp(strtotime($this->item->getUpdatedAt()));
$categoryItemObject->setSortOrder($sortIndex);
break;
case Shopgate_Framework_Model_System_Config_Source_Item_Sort::SORT_TYPE_NEWEST:
$sortIndex = Mage::getModel('core/date')->timestamp(strtotime($this->item->getCreatedAt()));
$categoryItemObject->setSortOrder(Shopgate_Framework_Model_Export_Product_Csv::MAX_TIMESTAMP - $sortIndex);
break;
case Shopgate_Framework_Model_System_Config_Source_Item_Sort::SORT_TYPE_PRICE_DESC:
$sortIndex = round($this->item->getFinalPrice() * 100, 0);
$categoryItemObject->setSortOrder($sortIndex);
break;
case Shopgate_Framework_Model_System_Config_Source_Item_Sort::SORT_TYPE_POSITION:
$categoryItemObject->setSortOrder($link['max_position'] - $link['position']);
break;
default:
$categoryItemObject->setSortOrder($link['position']);
}
$result[$link['category_id']] = $categoryItemObject;
}
}
parent::setCategoryPaths($result);
}
示例3: 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;
}
示例4: handleAddResponse
public function handleAddResponse(Mage_Catalog_Model_Product $product, Mage_Core_Controller_Request_Http $request, Mage_Core_Controller_Response_Http $response)
{
$output = array('product_id' => $product->getId(), 'product_price' => $product->getFinalPrice(), 'product_image' => (string) Mage::helper('catalog/image')->init($product, 'image')->resize(150, 150), 'product_qty' => 1, 'quote_total' => $this->_getQuote()->getSubtotal(), 'quote_qty' => $this->_getQuote()->getItemsQty(), 'success' => true);
$transport = new Varien_Object($output);
$this->_retrieveHtmlResponse($transport);
Mage::dispatchEvent('swiftotter_addtocart_success_output', array('transport' => $transport));
$this->_send($response, $transport->getData(), 200);
}
示例5: getFinalPrice
public function getFinalPrice($qty = null)
{
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
$helper = Mage::helper('ism_newstore_members');
$price = Mage::getModel('catalog/product')->load($this->getId())->_getData('ism_newstoremembers_price');
$customerId = Mage::getSingleton('customer/session')->getId();
if ($price !== null && $helper->isMemberValid($customerId) && $helper->isMemberAddress($customerId)) {
return $price;
}
}
return parent::getFinalPrice($qty);
}
示例6: getFinalPrice
function getFinalPrice($qty = null)
{
if (!$this->currentlySelectedFit()) {
return parent::getFinalPrice($qty);
}
$vehicle = $this->vf_product->getFirstCurrentlySelectedFitment();
if (!$vehicle) {
return parent::getFinalPrice($qty);
}
$customPrice = $this->customPrice($vehicle);
if ($customPrice) {
return $customPrice;
}
return parent::getFinalPrice($qty);
}
示例7: getFinalPrice
function getFinalPrice($qty = null)
{
if (!$this->currentlySelectedFit()) {
return parent::getFinalPrice($qty);
}
$selection = $this->currentlySelectedFit();
$vehicle = $selection->getFirstVehicle();
if (!$vehicle) {
return parent::getFinalPrice($qty);
}
$customPrice = $this->customPrice($vehicle);
if ($customPrice) {
return $customPrice;
}
return parent::getFinalPrice($qty);
}
示例8: createIndexData
public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
{
$data = array();
$data['store_id'] = $attribute->getStoreId();
$data['entity_id'] = $object->getId();
$data['attribute_id'] = $attribute->getId();
$data['value'] = $object->getData($attribute->getAttributeCode());
if ($attribute->getAttributeCode() == 'price') {
$result = array();
foreach ($this->_customerGroups as $group) {
$object->setCustomerGroupId($group->getId());
$finalPrice = $object->getFinalPrice();
$row = $data;
$row['customer_group_id'] = $group->getId();
$row['value'] = $finalPrice;
$result[] = $row;
}
return $result;
}
return $data;
}
示例9: getFinalPrice
/**
* Retrieve product final price
*
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getFinalPrice($product)
{
return $product->getFinalPrice();
}
示例10: _preparePrice
/**
* Prepare price accordingly to percentage and store rates and round its
*
* @param Mage_Catalog_Model_Product $product
* @param float|int|string $price
* @param bool $isPercent
* @return float
*/
protected function _preparePrice($product, $price, $isPercent = false)
{
if ($isPercent && !empty($price)) {
$price = $product->getFinalPrice() * $price / 100;
}
$price = Mage::app()->getStore()->convertPrice($price);
$price = Mage::app()->getStore()->roundPrice($price);
return $price;
}
示例11: 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;
}
}
}
示例12: _getTierPrices
/**
* Get tier prices (formatted)
*
* @param Mage_Catalog_Model_Product $product
* @return array
*/
protected function _getTierPrices(Mage_Catalog_Model_Product $product)
{
if (null === $product) {
return array();
}
$prices = $product->getFormatedTierPrice();
$res = array();
if (is_array($prices)) {
foreach ($prices as $price) {
$price['price_qty'] = $price['price_qty'] * 1;
if ($product->getPrice() != $product->getFinalPrice()) {
if ($price['price'] < $product->getFinalPrice()) {
$price['savePercent'] = ceil(100 - 100 / $product->getFinalPrice() * $price['price']);
$price['formated_price'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'])), false);
$price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'], true)), false);
$res[] = $price;
}
} else {
if ($price['price'] < $product->getPrice()) {
$price['savePercent'] = ceil(100 - 100 / $product->getPrice() * $price['price']);
$price['formated_price'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'])), false);
$price['formated_price_incl_tax'] = Mage::app()->getStore()->formatPrice(Mage::app()->getStore()->convertPrice(Mage::helper('tax')->getPrice($product, $price['website_price'], true)), false);
$res[] = $price;
}
}
}
}
return $res;
}
示例13: 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() == Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes_Extend::DYNAMIC) {
if ($multiplyQty) {
return $selectionProduct->getFinalPrice($selectionQty) * $selectionQty;
} else {
return $selectionProduct->getFinalPrice($selectionQty);
}
} else {
if ($selectionProduct->getSelectionPriceType()) {
return $bundleProduct->getPrice() * $selectionProduct->getSelectionPriceValue() / 100 * $selectionQty;
} else {
return $selectionProduct->getSelectionPriceValue() * $selectionQty;
}
}
}
示例14: getProductData
/**
* @param Mage_Catalog_Model_Product $product
* @return array
*/
public function getProductData(Mage_Catalog_Model_Product $product)
{
$id = $product->getId();
if (!$this->helper()->shouldUseRealProductId()) {
$id = $product->getSku() ? $product->getSku() : md5($id);
}
$data = array('id' => $id, 'url' => $product->getProductUrl(), 'name' => $product->getName(), 'unit_price' => (double) $product->getPrice(), 'unit_sale_price' => (double) $product->getFinalPrice(), 'currency' => $this->_getCurrency(), 'description' => strip_tags($product->getShortDescription()), 'sku_code' => $product->getSku());
if ($this->helper()->shouldShowProductStockInfo()) {
$data['stock'] = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
}
$catIndex = $catNames = array();
$limit = 2;
$k = 0;
foreach ($product->getCategoryIds() as $catId) {
if (++$k > $limit) {
break;
}
if (!isset($catIndex[$catId])) {
$catIndex[$catId] = Mage::getModel('catalog/category')->load($catId);
}
$catNames[] = $catIndex[$catId]->getName();
}
if (isset($catNames[0])) {
$data['category'] = $catNames[0];
}
if (isset($catNames[1])) {
$data['subcategory'] = $catNames[1];
}
return $data;
}
示例15: _shouldExport
protected function _shouldExport(Mage_Catalog_Model_Product $product)
{
if ($this->_filterPrice && $product->getFinalPrice() < $this->_filterPrice) {
return false;
}
if ($this->_isComplexProduct($product)) {
return true;
}
if (!$this->_filterStock && !$product->getStockItem()->getIsInStock()) {
return false;
}
if (!$this->_filterStock && $this->_filterStockFrom && $this->_stock[$product->getId()] < $this->_filterStockFrom) {
return false;
}
return true;
}