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


PHP AbstractModel::getId方法代码示例

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


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

示例1: _clearUselessAttributeValues

 /**
  * Clear useless attribute values
  *
  * @param  \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _clearUselessAttributeValues(\Magento\Framework\Model\AbstractModel $object)
 {
     $origData = $object->getOrigData();
     if ($object->isScopeGlobal() && isset($origData['is_global']) && \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL != $origData['is_global']) {
         $attributeStoreIds = array_keys($this->_storeManager->getStores());
         if (!empty($attributeStoreIds)) {
             $delCondition = ['attribute_id = ?' => $object->getId(), 'store_id IN(?)' => $attributeStoreIds];
             $this->getConnection()->delete($object->getBackendTable(), $delCondition);
         }
     }
     return $this;
 }
开发者ID:CompassPointMedia,项目名称:magento2,代码行数:18,代码来源:Attribute.php

示例2: _afterSave

 /**
  * Perform actions after object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->getGroups()) {
         /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */
         foreach ($object->getGroups() as $group) {
             $group->setAttributeSetId($object->getId());
             if ($group->itemExists() && !$group->getId()) {
                 continue;
             }
             $group->save();
         }
     }
     if ($object->getRemoveGroups()) {
         foreach ($object->getRemoveGroups() as $group) {
             /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */
             $group->delete();
         }
         $this->_attrGroupFactory->create()->updateDefaultGroup($object->getId());
     }
     if ($object->getRemoveAttributes()) {
         foreach ($object->getRemoveAttributes() as $attribute) {
             /* @var $attribute \Magento\Eav\Model\Entity\Attribute */
             $attribute->deleteEntity();
         }
     }
     return parent::_afterSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:33,代码来源:Set.php

示例3: processRelation

 /**
  * Save relations for Customer
  *
  * @param \Magento\Framework\Model\AbstractModel $customer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function processRelation(\Magento\Framework\Model\AbstractModel $customer)
 {
     $defaultBillingId = $customer->getData('default_billing');
     $defaultShippingId = $customer->getData('default_shipping');
     /** @var \Magento\Customer\Model\Address $address */
     foreach ($customer->getAddresses() as $address) {
         if ($address->getData('_deleted')) {
             if ($address->getId() == $defaultBillingId) {
                 $customer->setData('default_billing', null);
             }
             if ($address->getId() == $defaultShippingId) {
                 $customer->setData('default_shipping', null);
             }
             $removedAddressId = $address->getId();
             $address->delete();
             // Remove deleted address from customer address collection
             $customer->getAddressesCollection()->removeItemByKey($removedAddressId);
         } else {
             $address->setParentId($customer->getId())->setStoreId($customer->getStoreId())->setIsCustomerSaveTransaction(true)->save();
             if (($address->getIsPrimaryBilling() || $address->getIsDefaultBilling()) && $address->getId() != $defaultBillingId) {
                 $customer->setData('default_billing', $address->getId());
             }
             if (($address->getIsPrimaryShipping() || $address->getIsDefaultShipping()) && $address->getId() != $defaultShippingId) {
                 $customer->setData('default_shipping', $address->getId());
             }
         }
     }
     $changedAddresses = [];
     $changedAddresses['default_billing'] = $customer->getData('default_billing');
     $changedAddresses['default_shipping'] = $customer->getData('default_shipping');
     $customer->getResource()->getConnection()->update($customer->getResource()->getTable('customer_entity'), $changedAddresses, $customer->getResource()->getConnection()->quoteInto('entity_id = ?', $customer->getId()));
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:39,代码来源:Relation.php

示例4: _afterDelete

 /**
  * Delete all Nonce entries associated with the consumer
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 public function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     $adapter = $this->_getWriteAdapter();
     $adapter->delete($this->getTable('oauth_nonce'), array('consumer_id' => $object->getId()));
     $adapter->delete($this->getTable('oauth_token'), array('consumer_id' => $object->getId()));
     return parent::_afterDelete($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Consumer.php

示例5: _checkEntityIsEmpty

 /**
  * Check if Entity is Empty
  *
  * @return $this
  * @throws \InvalidArgumentException
  */
 protected function _checkEntityIsEmpty()
 {
     if (!$this->_entity->getId()) {
         throw new \InvalidArgumentException('The model is empty');
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Code.php

示例6: _afterDelete

 /**
  * Delete all Nonce entries associated with the consumer
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 public function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     $connection = $this->getConnection();
     $connection->delete($this->getTable('oauth_nonce'), ['consumer_id' => $object->getId()]);
     $connection->delete($this->getTable('oauth_token'), ['consumer_id' => $object->getId()]);
     return parent::_afterDelete($object);
 }
开发者ID:razbakov,项目名称:magento2,代码行数:13,代码来源:Consumer.php

示例7: saveModelAndFailOnUpdate

 /**
  * Callback for save method in mocked model
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function saveModelAndFailOnUpdate()
 {
     if (!$this->_model->getId()) {
         $this->saveModelSuccessfully();
     } else {
         throw new \Magento\Framework\Exception\LocalizedException(__('Synthetic model update failure.'));
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:13,代码来源:EntityTest.php

示例8: saveTestData

 /**
  * Saving test data to database
  * @return mixed
  */
 protected function saveTestData()
 {
     foreach ($this->getTestData() as $key => $value) {
         $this->model->setData($key, $value);
     }
     $this->model->save();
     return $this->model->getId();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:PasswordResetRequestEventTest.php

示例9: _afterLoad

 /**
  * Perform operations after object load
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterLoad(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->getId()) {
         $productIds = $this->lookupProductIds($object->getId());
         $productId = implode(',', $productIds);
         $object->setData('product_id', $productId);
     }
     return parent::_afterLoad($object);
 }
开发者ID:vladankuzmanovic,项目名称:ProductFaq,代码行数:15,代码来源:Question.php

示例10: aroundDelete

 /**
  * Reindex on product delete
  *
  * @param \Magento\Catalog\Model\ResourceModel\Product $productResource
  * @param \Closure $proceed
  * @param \Magento\Framework\Model\AbstractModel $product
  * @return \Magento\Catalog\Model\ResourceModel\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDelete(\Magento\Catalog\Model\ResourceModel\Product $productResource, \Closure $proceed, \Magento\Framework\Model\AbstractModel $product)
 {
     $productResource->addCommitCallback(function () use($product) {
         $this->reindexRow($product->getId());
     });
     return $proceed($product);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Product.php

示例11: processRelation

 /**
  * Save relations for Order
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return void
  * @throws \Exception
  */
 public function processRelation(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order $object */
     if (null !== $object->getItems()) {
         /** @var \Magento\Sales\Model\Order\Item $item */
         foreach ($object->getItems() as $item) {
             $item->setOrderId($object->getId());
             $item->setOrder($object);
             $this->orderItemRepository->save($item);
         }
     }
     if (null !== $object->getPayment()) {
         $payment = $object->getPayment();
         $payment->setParentId($object->getId());
         $payment->setOrder($object);
         $this->orderPaymentResource->save($payment);
     }
     if (null !== $object->getStatusHistories()) {
         /** @var \Magento\Sales\Model\Order\Status\History $statusHistory */
         foreach ($object->getStatusHistories() as $statusHistory) {
             $statusHistory->setParentId($object->getId());
             $statusHistory->setOrder($object);
             $this->orderStatusHistoryResource->save($statusHistory);
         }
     }
     if (null !== $object->getRelatedObjects()) {
         foreach ($object->getRelatedObjects() as $relatedObject) {
             $relatedObject->setOrder($object);
             $relatedObject->save();
         }
     }
     $this->addressHandler->removeEmptyAddresses($object);
     $this->addressHandler->process($object);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:41,代码来源:Relation.php

示例12: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 public function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($date = $object->getDateFrom()) {
         $object->setDateFrom($this->dateTime->formatDate($date));
     } else {
         $object->setDateFrom(null);
     }
     if ($date = $object->getDateTo()) {
         $object->setDateTo($this->dateTime->formatDate($date));
     } else {
         $object->setDateTo(null);
     }
     if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && $this->dateTime->toTimestamp($object->getDateFrom()) > $this->dateTime->toTimestamp($object->getDateTo())) {
         throw new \Magento\Framework\Model\Exception(__('Start date cannot be greater than end date.'));
     }
     $check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
     if ($check) {
         throw new \Magento\Framework\Model\Exception(__('Your design change for the specified store intersects with another one, please specify another date range.'));
     }
     if ($object->getDateFrom() === null) {
         $object->setDateFrom(new \Zend_Db_Expr('null'));
     }
     if ($object->getDateTo() === null) {
         $object->setDateTo(new \Zend_Db_Expr('null'));
     }
     parent::_beforeSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:Design.php

示例13: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($date = $object->getDateFrom()) {
         $object->setDateFrom($this->dateTime->formatDate($date));
     } else {
         $object->setDateFrom(null);
     }
     if ($date = $object->getDateTo()) {
         $object->setDateTo($this->dateTime->formatDate($date));
     } else {
         $object->setDateTo(null);
     }
     if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && (new \DateTime($object->getDateFrom()))->getTimestamp() > (new \DateTime($object->getDateTo()))->getTimestamp()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The start date can\'t follow the end date.'));
     }
     $check = $this->_checkIntersection($object->getStoreId(), $object->getDateFrom(), $object->getDateTo(), $object->getId());
     if ($check) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The date range for this design change overlaps another design change for the specified store.'));
     }
     if ($object->getDateFrom() === null) {
         $object->setDateFrom(new \Zend_Db_Expr('null'));
     }
     if ($object->getDateTo() === null) {
         $object->setDateTo(new \Zend_Db_Expr('null'));
     }
     parent::_beforeSave($object);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:Design.php

示例14: _beforeSave

 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getId()) {
         $object->setCreatedAt($this->_date->gmtDate());
     }
     $object->setUpdatedAt($this->_date->gmtDate());
     return $this;
 }
开发者ID:pradeeprcs,项目名称:TestModule,代码行数:8,代码来源:Test.php

示例15: _afterLoad

 /**
  * Method to run after load
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterLoad(\Magento\Framework\Model\AbstractModel $object)
 {
     $select = $this->getConnection()->select()->from($this->getTable('checkout_agreement_store'), ['store_id'])->where('agreement_id = :agreement_id');
     if ($stores = $this->getConnection()->fetchCol($select, [':agreement_id' => $object->getId()])) {
         $object->setData('store_id', $stores);
     }
     return parent::_afterLoad($object);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Agreement.php


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