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


PHP DataObject::setStoreId方法代码示例

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


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

示例1: beforeSave

 /**
  * Before save
  *
  * @param \Magento\Framework\DataObject $object
  * @return $this
  */
 public function beforeSave($object)
 {
     if ($object->getId()) {
         return $this;
     }
     if (!$object->hasStoreId()) {
         $object->setStoreId($this->_storeManager->getStore()->getId());
     }
     if (!$object->hasData('created_in')) {
         $object->setData('created_in', $this->_storeManager->getStore($object->getStoreId())->getName());
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Store.php

示例2: _beforeSave

 /**
  * Check customer scope, email and confirmation key before saving
  *
  * @param \Magento\Framework\DataObject $customer
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _beforeSave(\Magento\Framework\DataObject $customer)
 {
     /** @var \Magento\Customer\Model\Customer $customer */
     if ($customer->getStoreId() === null) {
         $customer->setStoreId($this->storeManager->getStore()->getId());
     }
     $customer->getGroupId();
     parent::_beforeSave($customer);
     if (!$customer->getEmail()) {
         throw new ValidatorException(__('Please enter a customer email.'));
     }
     $connection = $this->getConnection();
     $bind = ['email' => $customer->getEmail()];
     $select = $connection->select()->from($this->getEntityTable(), [$this->getEntityIdField()])->where('email = :email');
     if ($customer->getSharingConfig()->isWebsiteScope()) {
         $bind['website_id'] = (int) $customer->getWebsiteId();
         $select->where('website_id = :website_id');
     }
     if ($customer->getId()) {
         $bind['entity_id'] = (int) $customer->getId();
         $select->where('entity_id != :entity_id');
     }
     $result = $connection->fetchOne($select, $bind);
     if ($result) {
         throw new AlreadyExistsException(__('A customer with the same email already exists in an associated website.'));
     }
     // set confirmation key logic
     if ($customer->getForceConfirmed() || $customer->getPasswordHash() == '') {
         $customer->setConfirmation(null);
     } elseif (!$customer->getId() && $customer->isConfirmationRequired()) {
         $customer->setConfirmation($customer->getRandomConfirmationKey());
     }
     // remove customer confirmation key from database, if empty
     if (!$customer->getConfirmation()) {
         $customer->setConfirmation(null);
     }
     $this->_validate($customer);
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:48,代码来源:Customer.php

示例3: _getAllProductImages

 /**
  * Get all product images
  *
  * @param \Magento\Framework\DataObject $product
  * @param int $storeId
  * @return array
  */
 protected function _getAllProductImages($product, $storeId)
 {
     $product->setStoreId($storeId);
     $gallery = $this->_mediaAttribute->loadProductGalleryByAttributeId($product, $this->_getMediaGalleryModel()->getAttribute()->getId());
     $imagesCollection = [];
     if ($gallery) {
         $productMediaPath = $this->_getMediaConfig()->getBaseMediaUrlAddition();
         foreach ($gallery as $image) {
             $imagesCollection[] = new \Magento\Framework\DataObject(['url' => $productMediaPath . $image['file'], 'caption' => $image['label'] ? $image['label'] : $image['label_default']]);
         }
     }
     return $imagesCollection;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:20,代码来源:Product.php


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