本文整理汇总了PHP中Mage_Core_Model_Abstract::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getTitle方法的具体用法?PHP Mage_Core_Model_Abstract::getTitle怎么用?PHP Mage_Core_Model_Abstract::getTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Model_Abstract::getTitle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _saveValueTitles
/**
* Save titles
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Catalog_Model_Resource_Product_Option
*/
protected function _saveValueTitles(Mage_Core_Model_Abstract $object)
{
$readAdapter = $this->_getReadAdapter();
$writeAdapter = $this->_getWriteAdapter();
$titleTable = $this->getTable('catalog/product_option_title');
//title
if (!$object->getData('scope', 'title')) {
$statement = $readAdapter->select()->from($titleTable)->where('option_id = ?', $object->getId())->where('store_id = ?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
if ($readAdapter->fetchOne($statement)) {
if ($object->getStoreId() == '0') {
$data = $this->_prepareDataForTable(new Varien_Object(array('title' => $object->getTitle(), 'class' => $object->getClass())), $titleTable);
$writeAdapter->update($titleTable, $data, array('option_id = ?' => $object->getId(), 'store_id = ?' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID));
}
} else {
$data = $this->_prepareDataForTable(new Varien_Object(array('option_id' => $object->getId(), 'store_id' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID, 'title' => $object->getTitle(), 'class' => $object->getClass())), $titleTable);
$writeAdapter->insert($titleTable, $data);
}
}
if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) {
$statement = $readAdapter->select()->from($titleTable)->where('option_id = ?', $object->getId())->where('store_id = ?', $object->getStoreId());
if ($readAdapter->fetchOne($statement)) {
$data = $this->_prepareDataForTable(new Varien_Object(array('title' => $object->getTitle(), 'class' => $object->getClass())), $titleTable);
$writeAdapter->update($titleTable, $data, array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()));
} else {
$data = $this->_prepareDataForTable(new Varien_Object(array('option_id' => $object->getId(), 'store_id' => $object->getStoreId(), 'title' => $object->getTitle(), 'class' => $object->getClass())), $titleTable);
$writeAdapter->insert($titleTable, $data);
}
} elseif ($object->getData('scope', 'title')) {
$writeAdapter->delete($titleTable, array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()));
}
}
示例2: isUniqueCategory
public function isUniqueCategory(Mage_Core_Model_Abstract $object)
{
$title = trim($object->getTitle());
if (!empty($title)) {
$select = $this->_getReadAdapter()->select()->from($this->getMainTable(), $this->getIdFieldName())->where('title = ?', $title);
if ($object->getId()) {
$select->where($this->getIdFieldName() . ' <> ?', $object->getId());
}
if ($this->_getReadAdapter()->fetchRow($select)) {
return false;
}
}
return true;
}
示例3: _afterSave
/**
* Perform actions after object save
*
* @param Varien_Object $object
* @return Mage_Review_Model_Resource_Review
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$adapter = $this->_getWriteAdapter();
/**
* save detail
*/
$detail = array('title' => $object->getTitle(), 'detail' => $object->getDetail(), 'nickname' => $object->getNickname());
$select = $adapter->select()->from($this->_reviewDetailTable, 'detail_id')->where('review_id = :review_id');
$detailId = $adapter->fetchOne($select, array(':review_id' => $object->getId()));
if ($detailId) {
$condition = array("detail_id = ?" => $detailId);
$adapter->update($this->_reviewDetailTable, $detail, $condition);
} else {
$detail['store_id'] = $object->getStoreId();
$detail['customer_id'] = $object->getCustomerId();
$detail['review_id'] = $object->getId();
$adapter->insert($this->_reviewDetailTable, $detail);
}
/**
* save stores
*/
$stores = $object->getStores();
if (!empty($stores)) {
$condition = array('review_id = ?' => $object->getId());
$adapter->delete($this->_reviewStoreTable, $condition);
$insertedStoreIds = array();
foreach ($stores as $storeId) {
if (in_array($storeId, $insertedStoreIds)) {
continue;
}
$insertedStoreIds[] = $storeId;
$storeInsert = array('store_id' => $storeId, 'review_id' => $object->getId());
$adapter->insert($this->_reviewStoreTable, $storeInsert);
}
}
// reaggregate ratings, that depend on this review
$this->_aggregateRatings($this->_loadVotedRatingIds($object->getId()), $object->getEntityPkValue());
return $this;
}
示例4: _afterSave
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$priceTable = $this->getTable('catalog/product_option_price');
$titleTable = $this->getTable('catalog/product_option_title');
//better to check param 'price' and 'price_type' for saving. If there is not price scip saving price
if ($object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_AREA || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_FILE || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME || $object->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME) {
//save for store_id = 0
if (!$object->getData('scope', 'price')) {
$statement = $this->_getReadAdapter()->select()->from($priceTable)->where('option_id = ' . $object->getId() . ' AND store_id = ?', 0);
if ($this->_getReadAdapter()->fetchOne($statement)) {
if ($object->getStoreId() == '0') {
$this->_getWriteAdapter()->update($priceTable, array('price' => $object->getPrice(), 'price_type' => $object->getPriceType()), $this->_getWriteAdapter()->quoteInto('option_id = ' . $object->getId() . ' AND store_id = ?', 0));
}
} else {
$this->_getWriteAdapter()->insert($priceTable, array('option_id' => $object->getId(), 'store_id' => 0, 'price' => $object->getPrice(), 'price_type' => $object->getPriceType()));
}
}
$scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
if ($object->getStoreId() != '0' && $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE && !$object->getData('scope', 'price')) {
$baseCurrency = Mage::app()->getBaseCurrencyCode();
$storeIds = Mage::app()->getStore($object->getStoreId())->getWebsite()->getStoreIds();
if (is_array($storeIds)) {
foreach ($storeIds as $storeId) {
if ($object->getPriceType() == 'fixed') {
$storeCurrency = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
$rate = Mage::getModel('directory/currency')->load($baseCurrency)->getRate($storeCurrency);
if (!$rate) {
$rate = 1;
}
$newPrice = $object->getPrice() * $rate;
} else {
$newPrice = $object->getPrice();
}
$statement = $this->_getReadAdapter()->select()->from($priceTable)->where('option_id = ' . $object->getId() . ' AND store_id = ?', $storeId);
if ($this->_getReadAdapter()->fetchOne($statement)) {
$this->_getWriteAdapter()->update($priceTable, array('price' => $newPrice, 'price_type' => $object->getPriceType()), $this->_getWriteAdapter()->quoteInto('option_id = ' . $object->getId() . ' AND store_id = ?', $storeId));
} else {
$this->_getWriteAdapter()->insert($priceTable, array('option_id' => $object->getId(), 'store_id' => $storeId, 'price' => $newPrice, 'price_type' => $object->getPriceType()));
}
}
// end foreach()
}
} elseif ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE && $object->getData('scope', 'price')) {
$this->_getWriteAdapter()->delete($priceTable, $this->_getWriteAdapter()->quoteInto('option_id = ' . $object->getId() . ' AND store_id = ?', $object->getStoreId()));
}
}
//title
if (!$object->getData('scope', 'title')) {
$statement = $this->_getReadAdapter()->select()->from($titleTable)->where('option_id = ' . $object->getId() . ' and store_id = ?', 0);
if ($this->_getReadAdapter()->fetchOne($statement)) {
if ($object->getStoreId() == '0') {
$this->_getWriteAdapter()->update($titleTable, array('title' => $object->getTitle()), $this->_getWriteAdapter()->quoteInto('option_id=' . $object->getId() . ' AND store_id=?', 0));
}
} else {
$this->_getWriteAdapter()->insert($titleTable, array('option_id' => $object->getId(), 'store_id' => 0, 'title' => $object->getTitle()));
}
}
if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) {
$statement = $this->_getReadAdapter()->select()->from($titleTable)->where('option_id = ' . $object->getId() . ' and store_id = ?', $object->getStoreId());
if ($this->_getReadAdapter()->fetchOne($statement)) {
$this->_getWriteAdapter()->update($titleTable, array('title' => $object->getTitle()), $this->_getWriteAdapter()->quoteInto('option_id=' . $object->getId() . ' AND store_id=?', $object->getStoreId()));
} else {
$this->_getWriteAdapter()->insert($titleTable, array('option_id' => $object->getId(), 'store_id' => $object->getStoreId(), 'title' => $object->getTitle()));
}
} elseif ($object->getData('scope', 'title')) {
$this->_getWriteAdapter()->delete($titleTable, $this->_getWriteAdapter()->quoteInto('option_id = ' . $object->getId() . ' AND store_id = ?', $object->getStoreId()));
}
return parent::_afterSave($object);
}
示例5: _beforeSave
/**
* validate before saving
*
* @access protected
* @param $object
* @return Stovpak_Article_Model_Resource_Article
* @author Ultimate Module Creator
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
$urlKey = $object->getData('url_key');
if ($urlKey == '') {
$urlKey = $object->getTitle();
}
$urlKey = $this->formatUrlKey($urlKey);
$validKey = false;
while (!$validKey) {
$entityId = $this->checkUrlKey($urlKey, $object->getStoreId(), false);
if ($entityId == $object->getId() || empty($entityId)) {
$validKey = true;
} else {
$parts = explode('-', $urlKey);
$last = $parts[count($parts) - 1];
if (!is_numeric($last)) {
$urlKey = $urlKey . '-1';
} else {
$suffix = '-' . ($last + 1);
unset($parts[count($parts) - 1]);
$urlKey = implode('-', $parts) . $suffix;
}
}
}
$object->setData('url_key', $urlKey);
return parent::_beforeSave($object);
}
示例6: _saveValueTitles
/**
* Save option value title data
*
* @param Mage_Core_Model_Abstract $object
*/
protected function _saveValueTitles(Mage_Core_Model_Abstract $object)
{
$titleTable = $this->getTable('catalog_product_option_type_title');
if (!$object->getData('scope', 'title')) {
$select = $this->_getReadAdapter()->select()->from($titleTable, array('option_type_id'))->where('option_type_id = ?', (int) $object->getId())->where('store_id = ?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
$optionTypeId = $this->_getReadAdapter()->fetchOne($select);
if ($optionTypeId) {
if ($object->getStoreId() == '0') {
$where = array('option_type_id = ?' => (int) $optionTypeId, 'store_id = ?' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
$bind = array('title' => $object->getTitle());
$this->_getWriteAdapter()->update($titleTable, $bind, $where);
}
} else {
$bind = array('option_type_id' => (int) $object->getId(), 'store_id' => Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID, 'title' => $object->getTitle());
$this->_getWriteAdapter()->insert($titleTable, $bind);
}
}
if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) {
$select = $this->_getReadAdapter()->select()->from($titleTable, array('option_type_id'))->where('option_type_id = ?', (int) $object->getId())->where('store_id = ?', (int) $object->getStoreId());
$optionTypeId = $this->_getReadAdapter()->fetchOne($select);
if ($optionTypeId) {
$bind = array('title' => $object->getTitle());
$where = array('option_type_id = ?' => (int) $optionTypeId, 'store_id = ?' => (int) $object->getStoreId());
$this->_getWriteAdapter()->update($titleTable, $bind, $where);
} else {
$bind = array('option_type_id' => (int) $object->getId(), 'store_id' => (int) $object->getStoreId(), 'title' => $object->getTitle());
$this->_getWriteAdapter()->insert($titleTable, $bind);
}
} else {
if ($object->getData('scope', 'title')) {
$where = array('option_type_id = ?' => (int) $object->getId(), 'store_id = ?' => (int) $object->getStoreId());
$this->_getWriteAdapter()->delete($titleTable, $where);
}
}
}