当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractModel::getType方法代码示例

本文整理汇总了PHP中Magento\Framework\Model\AbstractModel::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getType方法的具体用法?PHP AbstractModel::getType怎么用?PHP AbstractModel::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Model\AbstractModel的用法示例。


在下文中一共展示了AbstractModel::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _beforeSave

 /**
  * Check if semilar event exist before start saving data
  *
  * @param AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     /**
      * Check if event already exist and merge previous data
      */
     if (!$object->getId()) {
         $select = $this->_getReadAdapter()->select()->from($this->getMainTable())->where('type=?', $object->getType())->where('entity=?', $object->getEntity());
         if ($object->hasEntityPk()) {
             $select->where('entity_pk=?', $object->getEntityPk());
         }
         $data = $this->_getWriteAdapter()->fetchRow($select);
         if ($data) {
             $object->mergePreviousData($data);
         }
     }
     $object->cleanNewData();
     return parent::_beforeSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:24,代码来源:Event.php

示例2: saveReferenceTerms

 /**
  * Saves reference terms for a thesaurus. Reference term are used by expansions thesaurus only.
  *
  * @param \Magento\Framework\Model\AbstractModel $object         Thesaurus to save
  * @param array                                  $referenceTerms Thesaurus reference terms
  *
  * @return $this
  */
 private function saveReferenceTerms(\Magento\Framework\Model\AbstractModel $object, $referenceTerms)
 {
     if ($object->getType() === ThesaurusInterface::TYPE_EXPANSION) {
         $this->getConnection()->insertOnDuplicate($this->getTable(ThesaurusInterface::REFERENCE_TABLE_NAME), $referenceTerms, array_keys(current($referenceTerms)));
     }
     return $this;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:15,代码来源:Thesaurus.php

示例3: _saveValuePrices

 /**
  * Save value prices
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $object)
 {
     $priceTable = $this->getTable('catalog_product_option_price');
     $connection = $this->getConnection();
     /*
      * Better to check param 'price' and 'price_type' for saving.
      * If there is not price skip saving price
      */
     if ($object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FIELD || $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_AREA || $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_FILE || $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE || $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DATE_TIME || $object->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_TIME) {
         //save for store_id = 0
         if (!$object->getData('scope', 'price')) {
             $statement = $connection->select()->from($priceTable, 'option_id')->where('option_id = ?', $object->getId())->where('store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID);
             $optionId = $connection->fetchOne($statement);
             if ($optionId) {
                 if ($object->getStoreId() == '0') {
                     $data = $this->_prepareDataForTable(new \Magento\Framework\DataObject(['price' => $object->getPrice(), 'price_type' => $object->getPriceType()]), $priceTable);
                     $connection->update($priceTable, $data, ['option_id = ?' => $object->getId(), 'store_id  = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID]);
                 }
             } else {
                 $data = $this->_prepareDataForTable(new \Magento\Framework\DataObject(['option_id' => $object->getId(), 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, 'price' => $object->getPrice(), 'price_type' => $object->getPriceType()]), $priceTable);
                 $connection->insert($priceTable, $data);
             }
         }
         $scope = (int) $this->_config->getValue(\Magento\Store\Model\Store::XML_PATH_PRICE_SCOPE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         if ($object->getStoreId() != '0' && $scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE) {
             $baseCurrency = $this->_config->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, 'default');
             $storeIds = $this->_storeManager->getStore($object->getStoreId())->getWebsite()->getStoreIds();
             if (is_array($storeIds)) {
                 foreach ($storeIds as $storeId) {
                     if ($object->getPriceType() == 'fixed') {
                         $storeCurrency = $this->_storeManager->getStore($storeId)->getBaseCurrencyCode();
                         $rate = $this->_currencyFactory->create()->load($baseCurrency)->getRate($storeCurrency);
                         if (!$rate) {
                             $rate = 1;
                         }
                         $newPrice = $object->getPrice() * $rate;
                     } else {
                         $newPrice = $object->getPrice();
                     }
                     $statement = $connection->select()->from($priceTable)->where('option_id = ?', $object->getId())->where('store_id  = ?', $storeId);
                     if ($connection->fetchOne($statement)) {
                         $data = $this->_prepareDataForTable(new \Magento\Framework\DataObject(['price' => $newPrice, 'price_type' => $object->getPriceType()]), $priceTable);
                         $connection->update($priceTable, $data, ['option_id = ?' => $object->getId(), 'store_id  = ?' => $storeId]);
                     } else {
                         $data = $this->_prepareDataForTable(new \Magento\Framework\DataObject(['option_id' => $object->getId(), 'store_id' => $storeId, 'price' => $newPrice, 'price_type' => $object->getPriceType()]), $priceTable);
                         $connection->insert($priceTable, $data);
                     }
                 }
             }
         } elseif ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE && $object->getData('scope', 'price')) {
             $connection->delete($priceTable, ['option_id = ?' => $object->getId(), 'store_id  = ?' => $object->getStoreId()]);
         }
     }
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:63,代码来源:Option.php


注:本文中的Magento\Framework\Model\AbstractModel::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。