本文整理汇总了PHP中Mage_Catalog_Model_Product::getCalculatedFinalPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getCalculatedFinalPrice方法的具体用法?PHP Mage_Catalog_Model_Product::getCalculatedFinalPrice怎么用?PHP Mage_Catalog_Model_Product::getCalculatedFinalPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Product
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Product::getCalculatedFinalPrice方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 = parent::getFinalPrice($qty, $product);
$product->getTypeInstance(true)->setStoreFilter($product->getStore(), $product);
$attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
$selectedAttributes = array();
if ($product->getCustomOption('attributes')) {
$selectedAttributes = unserialize($product->getCustomOption('attributes')->getValue());
}
$basePrice = $finalPrice;
foreach ($attributes as $attribute) {
$attributeId = $attribute->getProductAttribute()->getId();
$value = $this->_getValueByIndex($attribute->getPrices() ? $attribute->getPrices() : array(), isset($selectedAttributes[$attributeId]) ? $selectedAttributes[$attributeId] : null);
if ($value) {
if ($value['pricing_value'] != 0) {
$finalPrice += $this->_calcSelectionPrice($value, $basePrice);
}
}
}
$product->setFinalPrice($finalPrice);
return max(0, $product->getData('final_price'));
}
示例2: getFinalPrice
/**
* Retrieve product final price
*
* @param float|null $qty
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = $this->getBasePrice($product, $qty);
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$finalPrice = max(0, $finalPrice);
$product->setFinalPrice($finalPrice);
$session = Mage::getSingleton('core/session');
$session_geo_ip = $session->getGeoIp();
if (isset($session_geo_ip['is_changed'])) {
$model_city = $session->getGeoIp();
} else {
$model_city = Mage::getModel('geoip/abstract')->data;
}
if (isset($model_city['code']) && $model_city['code'] != '2137') {
$price_add = Mage::getStoreConfig('shipping/option/checkout_multiple_maximum_qty');
$finalPrice = $finalPrice + $price_add;
}
return $finalPrice;
}
示例3: getFinalPrice
/**
* Returns product final price depending on options chosen
*
* @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 = parent::getFinalPrice($qty, $product);
if ($product->hasCustomOptions()) {
/* @var $typeInstance Mage_Catalog_Model_Product_Type_Grouped */
$typeInstance = $product->getTypeInstance(true);
$associatedProducts = $typeInstance->setStoreFilter($product->getStore(), $product)->getAssociatedProducts($product);
foreach ($associatedProducts as $childProduct) {
/* @var $childProduct Mage_Catalog_Model_Product */
$option = $product->getCustomOption('associated_product_' . $childProduct->getId());
if (!$option) {
continue;
}
$childQty = $option->getValue();
if (!$childQty) {
continue;
}
$finalPrice += $childProduct->getFinalPrice($childQty) * $childQty;
}
}
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_type_grouped_price', array('product' => $product));
return max(0, $product->getData('final_price'));
}
示例4: 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();
$basePrice = $finalPrice;
/**
* Just product with fixed price calculation has price
*/
if ($finalPrice) {
$tierPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$specialPrice = $this->_applySpecialPrice($product, $finalPrice);
$finalPrice = min(array($tierPrice, $specialPrice));
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product));
$finalPrice = $product->getData('final_price');
}
$basePrice = $finalPrice;
if ($product->hasCustomOptions()) {
$customOption = $product->getCustomOption('bundle_option_ids');
$customOption = $product->getCustomOption('bundle_selection_ids');
$selectionIds = unserialize($customOption->getValue());
$selections = $product->getTypeInstance(true)->getSelectionsByIds($selectionIds, $product);
$selections->addTierPriceData();
Mage::dispatchEvent('prepare_catalog_product_collection_prices', array('collection' => $selections, 'store_id' => $product->getStoreId()));
foreach ($selections->getItems() as $selection) {
if ($selection->isSalable()) {
$selectionQty = $product->getCustomOption('selection_qty_' . $selection->getSelectionId());
if ($selectionQty) {
$finalPrice = $finalPrice + $this->getSelectionFinalPrice($product, $selection, $qty, $selectionQty->getValue());
}
}
}
} else {
// if ($options = $this->getOptions($product)) {
// /* some strange thing
// foreach ($options as $option) {
// $selectionCount = count($option->getSelections());
// if ($selectionCount) {
// foreach ($option->getSelections() as $selection) {
// if ($selection->isSalable() && ($selection->getIsDefault() || ($option->getRequired() &&)) {
// $finalPrice = $finalPrice + $this->getSelectionPrice($product, $selection);
// }
// }
// }
// }
// */
// }
}
$finalPrice = $finalPrice + $this->_applyOptionsPrice($product, $qty, $basePrice) - $basePrice;
$product->setFinalPrice($finalPrice);
return max(0, $product->getData('final_price'));
}
示例5: getFinalPrice
/**
* Retrieve product final price
*
* @param float|null $qty
* @param Mage_Catalog_Model_Product $product
* @return float
*/
public function getFinalPrice($qty = null, $product)
{
if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
return $product->getCalculatedFinalPrice();
}
$finalPrice = $this->getBasePrice($product, $qty);
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$finalPrice = max(0, $finalPrice);
$product->setFinalPrice($finalPrice);
return $finalPrice;
}
示例6: 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();
if ($product->hasCustomOptions()) {
$customOption = $product->getCustomOption('bundle_option_ids');
$optionIds = unserialize($customOption->getValue());
$customOption = $product->getCustomOption('bundle_selection_ids');
$selectionIds = unserialize($customOption->getValue());
$selections = $product->getTypeInstance()->getSelectionsByIds($selectionIds);
foreach ($selections->getItems() as $selection) {
if ($selection->isSalable()) {
$selectionQty = $product->getCustomOption('selection_qty_' . $selection->getSelectionId());
if ($selectionQty) {
$finalPrice = $finalPrice + $this->getSelectionPrice($product, $selection, $selectionQty->getValue());
}
}
}
} else {
if ($options = $this->getOptions($product)) {
/* some strange thing
foreach ($options as $option) {
$selectionCount = count($option->getSelections());
if ($selectionCount) {
foreach ($option->getSelections() as $selection) {
if ($selection->isSalable() && ($selection->getIsDefault() || ($option->getRequired() &&)) {
$finalPrice = $finalPrice + $this->getSelectionPrice($product, $selection);
}
}
}
}
*/
}
}
$finalPrice = $this->_applyTierPrice($product, $qty, $finalPrice);
$finalPrice = $this->_applySpecialPrice($product, $finalPrice);
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
return max(0, $product->getData('final_price'));
}
示例7: 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);
}
}
示例8: 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 = $this->getBasePrice($product, $qty);
// $product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
$finalPrice = 0;
//$product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$finalPrice += $this->getTotalBundleItemsPrice($product, $qty);
$product->setFinalPrice($finalPrice);
if ($this->getTotalBundleItemsPrice($product, $qty) == 0) {
return max(0, $product->getData('special_price'));
} else {
return max(0, $product->getData('final_price'));
}
}
示例9: 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 = $this->getBasePrice($product, $qty);
$product->setFinalPrice($finalPrice);
Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
$finalPrice = $product->getData('final_price');
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
$isReservation = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'is_reservation');
$bundlePriceType = ITwebexperts_Payperrentals_Helper_Data::getAttributeCodeForId($product->getId(), 'bundle_pricingtype');
if ($isReservation != ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_DISABLED) {
if ($bundlePriceType == ITwebexperts_Payperrentals_Model_Product_Bundlepricingtype::PRICING_BUNDLE_FORALL) {
if (is_object($product->getCustomOption('info_buyRequest'))) {
$source = unserialize($product->getCustomOption('info_buyRequest')->getValue());
if (isset($source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION])) {
$startingDate = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::START_DATE_OPTION];
$endingDate = $source[ITwebexperts_Payperrentals_Model_Product_Type_Reservation::END_DATE_OPTION];
}
}
if (isset($startingDate) && isset($endingDate)) {
$customerGroup = ITwebexperts_Payperrentals_Helper_Data::getCustomerGroup();
$finalPrice = ITwebexperts_Payperrentals_Helper_Price::calculatePrice($product->getId(), $startingDate, $endingDate, $qty, $customerGroup);
}
} else {
$finalPrice = $this->getTotalBundleItemsPrice($product, $qty);
}
} else {
$finalPrice += $this->getTotalBundleItemsPrice($product, $qty);
}
$product->setFinalPrice($finalPrice);
return max(0, $product->getData('final_price'));
}