本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getTitle方法的具体用法?PHP AbstractModel::getTitle怎么用?PHP AbstractModel::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Model\AbstractModel
的用法示例。
在下文中一共展示了AbstractModel::getTitle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Process tag data before saving
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
{
$object->setTitle(trim(strtolower($object->getTitle())));
if (!$object->getId()) {
$tag = $object->getCollection()->addFieldToFilter('title', $object->getTitle())->setPageSize(1)->getFirstItem();
if ($tag->getId()) {
throw new \Magento\Framework\Exception\LocalizedException(__('The tag is already exist.'));
}
}
$identifierGenerator = \Magento\Framework\App\ObjectManager::getInstance()->create('Magefan\\Blog\\Model\\ResourceModel\\PageIdentifierGenerator');
$identifierGenerator->generate($object);
if (!$this->isValidPageIdentifier($object)) {
throw new \Magento\Framework\Exception\LocalizedException(__('The tag URL key contains capital letters or disallowed symbols.'));
}
if ($this->isNumericPageIdentifier($object)) {
throw new \Magento\Framework\Exception\LocalizedException(__('The tag URL key cannot be made of only numbers.'));
}
return parent::_beforeSave($object);
}
示例2: _afterSave
/**
* Perform actions after object save
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
protected function _afterSave(AbstractModel $object)
{
$adapter = $this->_getWriteAdapter();
/**
* save detail
*/
$detail = ['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, [':review_id' => $object->getId()]);
if ($detailId) {
$condition = ["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 = ['review_id = ?' => $object->getId()];
$adapter->delete($this->_reviewStoreTable, $condition);
$insertedStoreIds = [];
foreach ($stores as $storeId) {
if (in_array($storeId, $insertedStoreIds)) {
continue;
}
$insertedStoreIds[] = $storeId;
$storeInsert = ['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;
}
示例3: _getModelName
/**
* Retrieve model name
* @param boolean $plural
* @return string
*/
protected function _getModelName(\Magento\Framework\Model\AbstractModel $model)
{
return $model->getName() ?: $model->getTitle();
}
示例4: _saveValueTitles
/**
* Save option value title data
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return void
*/
protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $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 = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
$optionTypeId = $this->_getReadAdapter()->fetchOne($select);
if ($optionTypeId) {
if ($object->getStoreId() == '0') {
$where = array('option_type_id = ?' => (int) $optionTypeId, 'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID);
$bind = array('title' => $object->getTitle());
$bind = array('title' => $object->getTitle());
$this->_getWriteAdapter()->update($titleTable, $bind, $where);
}
} else {
$bind = array('option_type_id' => (int) $object->getId(), 'store_id' => \Magento\Store\Model\Store::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);
}
}
}
示例5: _saveValueTitles
/**
* Save titles
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object)
{
$connection = $this->getConnection();
$titleTableName = $this->getTable('catalog_product_option_title');
foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) {
$existInCurrentStore = $this->getColFromOptionTable($titleTableName, (int) $object->getId(), (int) $storeId);
$existInDefaultStore = $this->getColFromOptionTable($titleTableName, (int) $object->getId(), \Magento\Store\Model\Store::DEFAULT_STORE_ID);
if ($object->getTitle()) {
if ($existInCurrentStore) {
if ($object->getStoreId() == $storeId) {
$data = $this->_prepareDataForTable(new \Magento\Framework\DataObject(['title' => $object->getTitle()]), $titleTableName);
$connection->update($titleTableName, $data, ['option_id = ?' => $object->getId(), 'store_id = ?' => $storeId]);
}
} else {
// we should insert record into not default store only of if it does not exist in default store
if ($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore || $storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore) {
$data = $this->_prepareDataForTable(new \Magento\Framework\DataObject(['option_id' => $object->getId(), 'store_id' => $storeId, 'title' => $object->getTitle()]), $titleTableName);
$connection->insert($titleTableName, $data);
}
}
} else {
if ($object->getId() && $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $storeId) {
$connection->delete($titleTableName, ['option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()]);
}
}
}
}
示例6: _saveValueTitles
/**
* Save option value title data
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object)
{
foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) {
$titleTable = $this->getTable('catalog_product_option_type_title');
$select = $this->_getReadAdapter()->select()->from($titleTable, ['option_type_id'])->where('option_type_id = ?', (int) $object->getId())->where('store_id = ?', (int) $storeId);
$optionTypeId = $this->_getReadAdapter()->fetchOne($select);
$existInCurrentStore = $this->getOptionIdFromOptionTable($titleTable, (int) $object->getId(), (int) $storeId);
if ($object->getTitle()) {
if ($existInCurrentStore) {
if ($storeId == $object->getStoreId()) {
$where = ['option_type_id = ?' => (int) $optionTypeId, 'store_id = ?' => $storeId];
$bind = ['title' => $object->getTitle()];
$this->_getWriteAdapter()->update($titleTable, $bind, $where);
}
} else {
$existInDefaultStore = $this->getOptionIdFromOptionTable($titleTable, (int) $object->getId(), \Magento\Store\Model\Store::DEFAULT_STORE_ID);
// we should insert record into not default store only of if it does not exist in default store
if ($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore || $storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore) {
$bind = ['option_type_id' => (int) $object->getId(), 'store_id' => $storeId, 'title' => $object->getTitle()];
$this->_getWriteAdapter()->insert($titleTable, $bind);
}
}
} else {
if ($storeId && $optionTypeId && $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID) {
$where = ['option_type_id = ?' => (int) $optionTypeId, 'store_id = ?' => $storeId];
$this->_getWriteAdapter()->delete($titleTable, $where);
}
}
}
}
示例7: _saveValueTitles
/**
* Save titles
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return void
*/
protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $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 = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
if ($readAdapter->fetchOne($statement)) {
if ($object->getStoreId() == '0') {
$data = $this->_prepareDataForTable(new \Magento\Framework\Object(array('title' => $object->getTitle())), $titleTable);
$writeAdapter->update($titleTable, $data, array('option_id = ?' => $object->getId(), 'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID));
}
} else {
$data = $this->_prepareDataForTable(new \Magento\Framework\Object(array('option_id' => $object->getId(), 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, 'title' => $object->getTitle())), $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 \Magento\Framework\Object(array('title' => $object->getTitle())), $titleTable);
$writeAdapter->update($titleTable, $data, array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()));
} else {
$data = $this->_prepareDataForTable(new \Magento\Framework\Object(array('option_id' => $object->getId(), 'store_id' => $object->getStoreId(), 'title' => $object->getTitle())), $titleTable);
$writeAdapter->insert($titleTable, $data);
}
} elseif ($object->getData('scope', 'title')) {
$writeAdapter->delete($titleTable, array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()));
}
}