本文整理汇总了PHP中Mage_Downloadable_Model_Link::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Downloadable_Model_Link::getPrice方法的具体用法?PHP Mage_Downloadable_Model_Link::getPrice怎么用?PHP Mage_Downloadable_Model_Link::getPrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Downloadable_Model_Link
的用法示例。
在下文中一共展示了Mage_Downloadable_Model_Link::getPrice方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveItemTitleAndPrice
/**
* Save title and price of link item
*
* @param Mage_Downloadable_Model_Link $linkObject
* @return Mage_Downloadable_Model_Mysql4_link
*/
public function saveItemTitleAndPrice($linkObject)
{
$stmt = $this->_getReadAdapter()->select()->from($this->getTable('downloadable/link_title'))->where('link_id = ?', $linkObject->getId())->where('store_id = ?', $linkObject->getStoreId());
if ($this->_getReadAdapter()->fetchOne($stmt)) {
$where = $this->_getReadAdapter()->quoteInto('link_id = ?', $linkObject->getId()) . ' AND ' . $this->_getReadAdapter()->quoteInto('store_id = ?', $linkObject->getStoreId());
if ($linkObject->getUseDefaultTitle()) {
$this->_getWriteAdapter()->delete($this->getTable('downloadable/link_title'), $where);
} else {
$this->_getWriteAdapter()->update($this->getTable('downloadable/link_title'), array('title' => $linkObject->getTitle()), $where);
}
} else {
if (!$linkObject->getUseDefaultTitle()) {
$this->_getWriteAdapter()->insert($this->getTable('downloadable/link_title'), array('link_id' => $linkObject->getId(), 'store_id' => $linkObject->getStoreId(), 'title' => $linkObject->getTitle()));
}
}
$stmt = null;
$stmt = $this->_getReadAdapter()->select()->from($this->getTable('downloadable/link_price'))->where('link_id = ?', $linkObject->getId())->where('website_id = ?', $linkObject->getWebsiteId());
if ($this->_getReadAdapter()->fetchOne($stmt)) {
$where = $this->_getReadAdapter()->quoteInto('link_id = ?', $linkObject->getId()) . ' AND ' . $this->_getReadAdapter()->quoteInto('website_id = ?', $linkObject->getWebsiteId());
if ($linkObject->getUseDefaultPrice()) {
$this->_getReadAdapter()->delete($this->getTable('downloadable/link_price'), $where);
} else {
$this->_getWriteAdapter()->update($this->getTable('downloadable/link_price'), array('price' => $linkObject->getPrice()), $where);
}
} else {
if (!$linkObject->getUseDefaultPrice()) {
$this->_getWriteAdapter()->insert($this->getTable('downloadable/link_price'), array('link_id' => $linkObject->getId(), 'website_id' => $linkObject->getWebsiteId(), 'price' => $linkObject->getPrice()));
}
}
return $this;
}
示例2: saveItemTitleAndPrice
/**
* Save title and price of link item
*
* @param Mage_Downloadable_Model_Link $linkObject
* @return Mage_Downloadable_Model_Resource_Link
*/
public function saveItemTitleAndPrice($linkObject)
{
$writeAdapter = $this->_getWriteAdapter();
$linkTitleTable = $this->getTable('downloadable/link_title');
$linkPriceTable = $this->getTable('downloadable/link_price');
$select = $writeAdapter->select()->from($this->getTable('downloadable/link_title'))->where('link_id=:link_id AND store_id=:store_id');
$bind = array(':link_id' => $linkObject->getId(), ':store_id' => (int) $linkObject->getStoreId());
if ($writeAdapter->fetchOne($select, $bind)) {
$where = array('link_id = ?' => $linkObject->getId(), 'store_id = ?' => (int) $linkObject->getStoreId());
if ($linkObject->getUseDefaultTitle()) {
$writeAdapter->delete($linkTitleTable, $where);
} else {
$insertData = array('title' => $linkObject->getTitle());
$writeAdapter->update($linkTitleTable, $insertData, $where);
}
} else {
if (!$linkObject->getUseDefaultTitle()) {
$writeAdapter->insert($linkTitleTable, array('link_id' => $linkObject->getId(), 'store_id' => (int) $linkObject->getStoreId(), 'title' => $linkObject->getTitle()));
}
}
$select = $writeAdapter->select()->from($linkPriceTable)->where('link_id=:link_id AND website_id=:website_id');
$bind = array(':link_id' => $linkObject->getId(), ':website_id' => (int) $linkObject->getWebsiteId());
if ($writeAdapter->fetchOne($select, $bind)) {
$where = array('link_id = ?' => $linkObject->getId(), 'website_id = ?' => $linkObject->getWebsiteId());
if ($linkObject->getUseDefaultPrice()) {
$writeAdapter->delete($linkPriceTable, $where);
} else {
$writeAdapter->update($linkPriceTable, array('price' => $linkObject->getPrice()), $where);
}
} else {
if (!$linkObject->getUseDefaultPrice()) {
$dataToInsert[] = array('link_id' => $linkObject->getId(), 'website_id' => (int) $linkObject->getWebsiteId(), 'price' => (double) $linkObject->getPrice());
if ($linkObject->getOrigData('link_id') != $linkObject->getLinkId()) {
$_isNew = true;
} else {
$_isNew = false;
}
if ($linkObject->getWebsiteId() == 0 && $_isNew && !Mage::helper('catalog')->isPriceGlobal()) {
$websiteIds = $linkObject->getProductWebsiteIds();
foreach ($websiteIds as $websiteId) {
$baseCurrency = Mage::app()->getBaseCurrencyCode();
$websiteCurrency = Mage::app()->getWebsite($websiteId)->getBaseCurrencyCode();
if ($websiteCurrency == $baseCurrency) {
continue;
}
$rate = Mage::getModel('directory/currency')->load($baseCurrency)->getRate($websiteCurrency);
if (!$rate) {
$rate = 1;
}
$newPrice = $linkObject->getPrice() * $rate;
$dataToInsert[] = array('link_id' => $linkObject->getId(), 'website_id' => (int) $websiteId, 'price' => $newPrice);
}
}
$writeAdapter->insertMultiple($linkPriceTable, $dataToInsert);
}
}
return $this;
}
示例3: saveItemTitleAndPrice
/**
* Save title and price of link item
*
* @param Mage_Downloadable_Model_Link $linkObject
* @return Mage_Downloadable_Model_Mysql4_link
*/
public function saveItemTitleAndPrice($linkObject)
{
$stmt = $this->_getReadAdapter()->select()->from($this->getTable('downloadable/link_title'))->where('link_id = ?', $linkObject->getId())->where('store_id = ?', $linkObject->getStoreId());
if ($this->_getReadAdapter()->fetchOne($stmt)) {
$where = $this->_getReadAdapter()->quoteInto('link_id = ?', $linkObject->getId()) . ' AND ' . $this->_getReadAdapter()->quoteInto('store_id = ?', $linkObject->getStoreId());
if ($linkObject->getUseDefaultTitle()) {
$this->_getWriteAdapter()->delete($this->getTable('downloadable/link_title'), $where);
} else {
$this->_getWriteAdapter()->update($this->getTable('downloadable/link_title'), array('title' => $linkObject->getTitle()), $where);
}
} else {
if (!$linkObject->getUseDefaultTitle()) {
$this->_getWriteAdapter()->insert($this->getTable('downloadable/link_title'), array('link_id' => $linkObject->getId(), 'store_id' => $linkObject->getStoreId(), 'title' => $linkObject->getTitle()));
}
}
$stmt = null;
$stmt = $this->_getReadAdapter()->select()->from($this->getTable('downloadable/link_price'))->where('link_id = ?', $linkObject->getId())->where('website_id = ?', $linkObject->getWebsiteId());
if ($this->_getReadAdapter()->fetchOne($stmt)) {
$where = $this->_getReadAdapter()->quoteInto('link_id = ?', $linkObject->getId()) . ' AND ' . $this->_getReadAdapter()->quoteInto('website_id = ?', $linkObject->getWebsiteId());
if ($linkObject->getUseDefaultPrice()) {
$this->_getReadAdapter()->delete($this->getTable('downloadable/link_price'), $where);
} else {
$this->_getWriteAdapter()->update($this->getTable('downloadable/link_price'), array('price' => $linkObject->getPrice()), $where);
}
} else {
if (!$linkObject->getUseDefaultPrice()) {
$dataToInsert[] = array('link_id' => $linkObject->getId(), 'website_id' => $linkObject->getWebsiteId(), 'price' => $linkObject->getPrice());
$_isNew = $linkObject->getOrigData('link_id') != $linkObject->getLinkId();
if ($linkObject->getWebsiteId() == 0 && $_isNew && !Mage::helper('catalog')->isPriceGlobal()) {
$websiteIds = $linkObject->getProductWebsiteIds();
foreach ($websiteIds as $websiteId) {
$baseCurrency = Mage::app()->getBaseCurrencyCode();
$websiteCurrency = Mage::app()->getWebsite($websiteId)->getBaseCurrencyCode();
if ($websiteCurrency == $baseCurrency) {
continue;
}
$rate = Mage::getModel('directory/currency')->load($baseCurrency)->getRate($websiteCurrency);
if (!$rate) {
$rate = 1;
}
$newPrice = $linkObject->getPrice() * $rate;
$dataToInsert[] = array('link_id' => $linkObject->getId(), 'website_id' => $websiteId, 'price' => $newPrice);
}
}
foreach ($dataToInsert as $_data) {
$this->_getWriteAdapter()->insert($this->getTable('downloadable/link_price'), $_data);
}
}
}
return $this;
}
示例4: getFormattedLinkPrice
/**
* Enter description here...
*
* @param Mage_Downloadable_Model_Link $link
* @return string
*/
public function getFormattedLinkPrice($link)
{
$price = $link->getPrice();
$store = $this->getProduct()->getStore();
if (0 == $price) {
return '';
}
$taxCalculation = Mage::getSingleton('Mage_Tax_Model_Calculation');
if (!$taxCalculation->getCustomer() && Mage::registry('current_customer')) {
$taxCalculation->setCustomer(Mage::registry('current_customer'));
}
$taxHelper = Mage::helper('Mage_Tax_Helper_Data');
$coreHelper = $this->helper('Mage_Core_Helper_Data');
$_priceInclTax = $taxHelper->getPrice($link->getProduct(), $price, true);
$_priceExclTax = $taxHelper->getPrice($link->getProduct(), $price);
$priceStr = '<span class="price-notice">+';
if ($taxHelper->displayPriceIncludingTax()) {
$priceStr .= $coreHelper->currencyByStore($_priceInclTax, $store);
} elseif ($taxHelper->displayPriceExcludingTax()) {
$priceStr .= $coreHelper->currencyByStore($_priceExclTax, $store);
} elseif ($taxHelper->displayBothPrices()) {
$priceStr .= $coreHelper->currencyByStore($_priceExclTax, $store);
if ($_priceInclTax != $_priceExclTax) {
$priceStr .= ' (+' . $coreHelper->currencyByStore($_priceInclTax, $store) . ' ' . $this->__('Incl. Tax') . ')';
}
}
$priceStr .= '</span>';
return $priceStr;
}
示例5: getFormattedLinkPrice
/**
* Enter description here...
*
* @param Mage_Downloadable_Model_Link $link
* @return string
*/
public function getFormattedLinkPrice($link)
{
$price = $link->getPrice();
if (0 == $price) {
return '';
}
$_priceInclTax = Mage::helper('tax')->getPrice($link->getProduct(), $price, true);
$_priceExclTax = Mage::helper('tax')->getPrice($link->getProduct(), $price);
$priceStr = '<span class="price-notice">+';
if (Mage::helper('tax')->displayPriceIncludingTax()) {
$priceStr .= $this->helper('core')->currency($_priceInclTax, true, true);
} elseif (Mage::helper('tax')->displayPriceExcludingTax()) {
$priceStr .= $this->helper('core')->currency($_priceExclTax, true, true);
} elseif (Mage::helper('tax')->displayBothPrices()) {
$priceStr .= $this->helper('core')->currency($_priceExclTax, true, true);
if ($_priceInclTax != $_priceExclTax) {
$priceStr .= ' (+' . $this->helper('core')->currency($_priceInclTax, true, true) . ' ' . $this->__('Incl. Tax') . ')';
}
}
$priceStr .= '</span>';
return $priceStr;
}