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


PHP AbstractModel::isObjectNew方法代码示例

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


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

示例1: _beforeSave

 /**
  * Prepare data to be saved to database
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\Object $object
  *
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->dateTime->formatDate(true));
     }
     $object->setUpdatedAt($this->dateTime->formatDate(true));
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:14,代码来源:Bookmark.php

示例2: beforeSave

 /**
  * Set created date
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 public function beforeSave($object)
 {
     $attributeCode = $this->getAttribute()->getAttributeCode();
     if ($object->isObjectNew() && $object->getData($attributeCode) === null) {
         $object->setData($attributeCode, gmdate(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
     }
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:Created.php

示例3: _beforeSave

 /**
  * Before saving the object, add the created or updated times
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
开发者ID:richdynamix,项目名称:personalised-products,代码行数:14,代码来源:Export.php

示例4: aroundSave

 /**
  * Invalidate indexer on store group save
  *
  * @param \Magento\Store\Model\Resource\Group $subject
  * @param \Closure $proceed
  * @param \Magento\Framework\Model\AbstractModel $group
  *
  * @return \Magento\Store\Model\Resource\Group
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(\Magento\Store\Model\Resource\Group $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $group)
 {
     $needInvalidation = !$group->isObjectNew() && $group->dataHasChangedFor('website_id');
     $result = $proceed($group);
     if ($needInvalidation) {
         $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();
     }
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:19,代码来源:Group.php

示例5: aroundSave

 /**
  * Invalidate indexer on store view save
  *
  * @param \Magento\Store\Model\ResourceModel\Store $subject
  * @param \Closure $proceed
  * @param \Magento\Framework\Model\AbstractModel $store
  *
  * @return \Magento\Store\Model\ResourceModel\Store
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(\Magento\Store\Model\ResourceModel\Store $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $store)
 {
     $needInvalidation = $store->isObjectNew();
     $result = $proceed($store);
     if ($needInvalidation) {
         $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();
     }
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:View.php

示例6: _beforeSave

 /**
  * Set template type, added at and modified at time
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(AbstractModel $object)
 {
     if ($object->isObjectNew()) {
         $object->setAddedAt($this->dateTime->formatDate(true));
     }
     $object->setModifiedAt($this->dateTime->formatDate(true));
     $object->setTemplateType((int) $object->getTemplateType());
     return parent::_beforeSave($object);
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:Template.php

示例7: aroundDelete

 /**
  * Invalidate indexer on searchable attribute delete
  *
  * @param \Magento\Catalog\Model\Resource\Attribute $subject
  * @param \Closure $proceed
  * @param \Magento\Framework\Model\AbstractModel $attribute
  *
  * @return \Magento\Catalog\Model\Resource\Attribute
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDelete(\Magento\Catalog\Model\Resource\Attribute $subject, \Closure $proceed, \Magento\Framework\Model\AbstractModel $attribute)
 {
     $needInvalidation = !$attribute->isObjectNew() && $attribute->getIsSearchable();
     $result = $proceed($attribute);
     if ($needInvalidation) {
         $this->indexerRegistry->get(Fulltext::INDEXER_ID)->invalidate();
     }
     return $result;
 }
开发者ID:nja78,项目名称:magento2,代码行数:19,代码来源:Attribute.php

示例8: beforeSave

 /**
  * Set created date
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 public function beforeSave($object)
 {
     $attributeCode = $this->getAttribute()->getAttributeCode();
     if ($object->isObjectNew() && $object->getData($attributeCode) === null) {
         //$object->setData($attributeCode, $this->dateTime->gmtDate());
         $object->setData($attributeCode, gmdate('Y-m-d H:i:s'));
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Created.php

示例9: _prepareDataForSave

 /**
  * Prepare data for save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return array
  */
 protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $currentTime = $this->dateTime->now();
     if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
         $object->setCreatedAt($currentTime);
     }
     $object->setUpdatedAt($currentTime);
     $data = parent::_prepareDataForSave($object);
     return $data;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:AbstractResource.php

示例10: _beforeSave

 /**
  * Set date of last update
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb
  */
 protected function _beforeSave(AbstractModel $object)
 {
     /* @var $object \ClassyLlama\AvaTax\Model\Queue */
     $date = $this->dateTime->gmtDate();
     if ($object->isObjectNew() && !$object->getCreatedAt()) {
         $object->setCreatedAt($date);
     } else {
         $object->setUpdatedAt($date);
     }
     return parent::_beforeSave($object);
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:17,代码来源:Queue.php

示例11: aroundSave

 /**
  * @param \Magento\Store\Model\ResourceModel\Group $object
  * @param callable $proceed
  * @param AbstractModel $group
  * @return \Magento\Store\Model\ResourceModel\Group
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(\Magento\Store\Model\ResourceModel\Group $object, \Closure $proceed, AbstractModel $group)
 {
     $originGroup = $group;
     $result = $proceed($originGroup);
     if (!$group->isObjectNew() && ($group->dataHasChangedFor('website_id') || $group->dataHasChangedFor('root_category_id'))) {
         $this->storeManager->reinitStores();
         foreach ($group->getStoreIds() as $storeId) {
             $this->urlPersist->deleteByData([UrlRewrite::STORE_ID => $storeId]);
         }
         $this->urlPersist->replace($this->generateCategoryUrls($group->getRootCategoryId(), $group->getStoreIds()));
         $this->urlPersist->replace($this->generateProductUrls($group->getWebsiteId(), $group->getOrigData('website_id')));
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:Group.php

示例12: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /* if (!$this->isValidPostLink_url($object)) {
                 throw new \Magento\Framework\Exception\LocalizedException(
                     __('The post URL key contains capital letters or disallowed symbols.')
                 );
             }
     
             if ($this->isNumericPostLink_url($object)) {
                 throw new \Magento\Framework\Exception\LocalizedException(
                     __('The post URL key cannot be made of only numbers.')
                 );
             }*/
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
开发者ID:OlgaBurtyka,项目名称:m2,代码行数:26,代码来源:Slider.php

示例13: aroundSave

 /**
  * @param \Magento\Sales\Model\Spi\InvoiceResourceInterface $subject
  * @param \Closure $proceed
  *
  *        I include both the extended AbstractModel and implemented Interface here for the IDE's benefit
  * @param \Magento\Framework\Model\AbstractModel|\Magento\Sales\Api\Data\InvoiceInterface $entity
  * @return \Magento\Sales\Model\Spi\InvoiceResourceInterface
  * @throws \Magento\Framework\Exception\CouldNotSaveException
  */
 public function aroundSave(InvoiceResourceInterface $subject, \Closure $proceed, AbstractModel $entity)
 {
     // Check to see if this is a newly created entity and store the determination for later evaluation after
     // the entity is saved via plugin closure. After the entity is saved it will not be listed as new any longer.
     $isObjectNew = $entity->isObjectNew();
     // Save AvaTax extension attributes
     if ($this->avaTaxConfig->isModuleEnabled($entity->getStoreId())) {
         // check to see if any extension attributes exist and set them on the model for saving to the db
         $extensionAttributes = $entity->getExtensionAttributes();
         if ($extensionAttributes && $extensionAttributes->getAvataxIsUnbalanced() !== null) {
             $entity->setData('avatax_is_unbalanced', $extensionAttributes->getAvataxIsUnbalanced());
         }
         if ($extensionAttributes && $extensionAttributes->getBaseAvataxTaxAmount() !== null) {
             $entity->setData('base_avatax_tax_amount', $extensionAttributes->getBaseAvataxTaxAmount());
         }
         // Updating a field to trigger a change to the record when avatax_is_unbalanced and base_avatax_tax_amount
         // are both false or 0 which evaluate the same as null in the isModified check
         if ($extensionAttributes && ($extensionAttributes->getAvataxIsUnbalanced() !== null && ($entity->getOrigData('avatax_is_unbalanced') === null || $extensionAttributes->getAvataxIsUnbalanced() != $entity->getOrigData('avatax_is_unbalanced')) || $extensionAttributes->getBaseAvataxTaxAmount() !== null && ($entity->getOrigData('base_avatax_tax_amount') === null || $extensionAttributes->getBaseAvataxTaxAmount() != $entity->getOrigData('base_avatax_tax_amount')))) {
             $entity->setUpdatedAt($this->dateTime->gmtDate());
         }
     }
     /** @var \Magento\Sales\Model\Spi\InvoiceResourceInterface $resultEntity */
     $resultEntity = $proceed($entity);
     /** @var \Magento\Sales\Model\Order $order */
     $order = $entity->getOrder();
     $isVirtual = $order->getIsVirtual();
     $address = $isVirtual ? $entity->getBillingAddress() : $entity->getShippingAddress();
     $storeId = $entity->getStoreId();
     // Queue the entity to be sent to AvaTax
     if ($this->avaTaxConfig->isModuleEnabled($entity->getStoreId()) && $this->avaTaxConfig->getTaxMode($entity->getStoreId()) == Config::TAX_MODE_ESTIMATE_AND_SUBMIT && $this->avaTaxConfig->isAddressTaxable($address, $storeId)) {
         // Add this entity to the avatax processing queue if this is a new entity
         if ($isObjectNew) {
             /** @var Queue $queue */
             $queue = $this->queueFactory->create();
             $queue->build($entity->getStoreId(), Queue::ENTITY_TYPE_CODE_INVOICE, $entity->getEntityId(), $entity->getIncrementId(), Queue::QUEUE_STATUS_PENDING);
             $queue->save();
             $this->avaTaxLogger->debug(__('Added entity to the queue'), ['queue_id' => $queue->getId(), 'entity_type_code' => Queue::ENTITY_TYPE_CODE_INVOICE, 'entity_id' => $entity->getEntityId()]);
         }
     }
     return $resultEntity;
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:50,代码来源:InvoiceResource.php

示例14: _beforeSave

 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     //        if (!$this->isValidPostUrlKey($object)) {
     //            throw new \Magento\Framework\Exception\LocalizedException(
     //            __('The post URL key contains capital letters or disallowed symbols.')
     //            );
     //        }
     //
     //        if ($this->isNumericPostUrlKey($object)) {
     //            throw new \Magento\Framework\Exception\LocalizedException(
     //            __('The post URL key cannot be made of only numbers.')
     //            );
     //        }
     //        $object->setData('photo_url', 'fefefefewfergrtgtrh');
     //        throw new \Magento\Framework\Exception\LocalizedException(
     //        __('Alert!! '.$object->getData('photo_url'))
     //        );
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
开发者ID:antonsbox,项目名称:testimonials,代码行数:30,代码来源:Post.php

示例15: _beforeSave

 /**
  * before save callback
  *
  * @param \Magento\Framework\Model\AbstractModel|\Mageplaza\Blog\Model\Topic $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     $object->setUpdatedAt($this->date->date());
     if ($object->isObjectNew()) {
         $object->setCreatedAt($this->date->date());
     }
     //Check Url Key
     if ($object->isObjectNew()) {
         $count = 0;
         $objName = $object->getName();
         if ($object->getUrlKey()) {
             $urlKey = $object->getUrlKey();
         } else {
             $urlKey = $this->generateUrlKey($objName, $count);
         }
         while ($this->checkUrlKey($urlKey)) {
             $count++;
             $urlKey = $this->generateUrlKey($urlKey, $count);
         }
         $object->setUrlKey($urlKey);
     } else {
         $objectId = $object->getId();
         $count = 0;
         $objName = $object->getName();
         if ($object->getUrlKey()) {
             $urlKey = $object->getUrlKey();
         } else {
             $urlKey = $this->generateUrlKey($objName, $count);
         }
         while ($this->checkUrlKey($urlKey, $objectId)) {
             $count++;
             $urlKey = $this->generateUrlKey($urlKey, $count);
         }
         $object->setUrlKey($urlKey);
     }
     return parent::_beforeSave($object);
 }
开发者ID:mageplaza,项目名称:magento-2-blog-extension,代码行数:43,代码来源:Topic.php


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