本文整理汇总了PHP中Mage_Downloadable_Model_Link::getProductWebsiteIds方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Downloadable_Model_Link::getProductWebsiteIds方法的具体用法?PHP Mage_Downloadable_Model_Link::getProductWebsiteIds怎么用?PHP Mage_Downloadable_Model_Link::getProductWebsiteIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Downloadable_Model_Link
的用法示例。
在下文中一共展示了Mage_Downloadable_Model_Link::getProductWebsiteIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}