當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractModel::getTitle方法代碼示例

本文整理匯總了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);
 }
開發者ID:magefan,項目名稱:module-blog,代碼行數:26,代碼來源:Tag.php

示例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;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:45,代碼來源:Review.php

示例3: _getModelName

 /**
  * Retrieve model name
  * @param  boolean $plural
  * @return string
  */
 protected function _getModelName(\Magento\Framework\Model\AbstractModel $model)
 {
     return $model->getName() ?: $model->getTitle();
 }
開發者ID:samitrimal,項目名稱:Blog-Extension-for-Magento-2,代碼行數:9,代碼來源:Actions.php

示例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);
         }
     }
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:42,代碼來源:Value.php

示例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()]);
             }
         }
     }
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:34,代碼來源:Option.php

示例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);
             }
         }
     }
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:37,代碼來源:Value.php

示例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()));
     }
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:37,代碼來源:Option.php


注:本文中的Magento\Framework\Model\AbstractModel::getTitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。