• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Api\GroupRepositoryInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Customer\Api\GroupRepositoryInterface的典型用法代码示例。如果您正苦于以下问题:PHP GroupRepositoryInterface类的具体用法?PHP GroupRepositoryInterface怎么用?PHP GroupRepositoryInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: init

 /**
  * {@inheritdoc}
  */
 public function init($context)
 {
     foreach ($this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems() as $group) {
         $this->customerGroups[$group->getId()] = true;
     }
     return parent::init($context);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:AbstractPrice.php


示例2: isAssignedToObjects

 /**
  * {@inheritdoc}
  */
 public function isAssignedToObjects()
 {
     $searchCriteria = $this->searchCriteriaBuilder->addFilter([$this->filterBuilder->setField(CustomerGroup::TAX_CLASS_ID)->setValue($this->getId())->create()])->create();
     $result = $this->customerGroupRepository->getList($searchCriteria);
     $items = $result->getItems();
     return !empty($items);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Customer.php


示例3: execute

 /**
  * @param Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute(Observer $observer)
 {
     if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
         /** @var \Magento\Customer\Model\Data\Customer $customer */
         $customer = $observer->getData('customer');
         $customerGroupId = $customer->getGroupId();
         $customerGroup = $this->groupRepository->getById($customerGroupId);
         $customerTaxClassId = $customerGroup->getTaxClassId();
         $this->customerSession->setCustomerTaxClassId($customerTaxClassId);
         /** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
         $addresses = $customer->getAddresses();
         if (isset($addresses)) {
             $defaultShippingFound = false;
             $defaultBillingFound = false;
             foreach ($addresses as $address) {
                 if ($address->isDefaultBilling()) {
                     $defaultBillingFound = true;
                     $this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($address->isDefaultShipping()) {
                     $defaultShippingFound = true;
                     $this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
                 }
                 if ($defaultShippingFound && $defaultBillingFound) {
                     break;
                 }
             }
         }
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:35,代码来源:CustomerLoggedInObserver.php


示例4: prepareDataSource

 /**
  * Prepare Data Source
  *
  * @param array $dataSource
  * @return void
  */
 public function prepareDataSource(array &$dataSource)
 {
     if (isset($dataSource['data']['items'])) {
         foreach ($dataSource['data']['items'] as &$item) {
             $item[$this->getData('name')] = $this->groupRepository->getById($item[$this->getData('name')])->getCode();
         }
     }
 }
开发者ID:nja78,项目名称:magento2,代码行数:14,代码来源:CustomerGroup.php


示例5: processInit

 protected function processInit($groupId)
 {
     $searchResult = $this->getMock('Magento\\Customer\\Api\\Data\\GroupSearchResultsInterface', [], [], '', false);
     $this->groupRepositoryInterface->expects($this->once())->method('getList')->willReturn($searchResult);
     $group = $this->getMock('Magento\\Customer\\Model\\Data\\Group', [], [], '', false);
     $group->expects($this->once())->method('getId')->willReturn($groupId);
     $searchResult->expects($this->once())->method('getItems')->willReturn([$group]);
     return $this->tierPrice->init(null);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:TierPriceTest.php


示例6: testGetCustomerGroupAttribute

 /**
  * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute
  */
 public function testGetCustomerGroupAttribute()
 {
     $this->document->setData('customer_group_id', 1);
     $group = $this->getMockForAbstractClass(GroupInterface::class);
     $this->groupRepository->expects(static::once())->method('getById')->willReturn($group);
     $group->expects(static::once())->method('getCode')->willReturn('General');
     $attribute = $this->document->getCustomAttribute('customer_group_id');
     static::assertEquals('General', $attribute->getValue());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:DocumentTest.php


示例7: loadSource

 /**
  * @return \Magento\Customer\Api\Data\GroupInterface
  */
 protected function loadSource()
 {
     if ($this->isBackendOrder()) {
         // For backend orders
         $customerGroupId = $this->objectManager->get('Magento\\Backend\\Model\\Session\\Quote')->getQuote()->getCustomerGroupId();
     } else {
         $customerGroupId = $this->objectManager->get('Magento\\Customer\\Model\\Session')->getCustomerGroupId();
     }
     return $this->groupRepository->getById($customerGroupId);
 }
开发者ID:owebia,项目名称:module-shipping-core,代码行数:13,代码来源:CustomerGroup.php


示例8: getHeaderText

 /**
  * Retrieve the header text, either editing an existing group or creating a new one.
  *
  * @return \Magento\Framework\Phrase
  */
 public function getHeaderText()
 {
     $groupId = $this->coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
     if ($groupId === null) {
         return __('New Customer Group');
     } else {
         $group = $this->groupRepository->getById($groupId);
         return __('Edit Customer Group "%1"', $this->escapeHtml($group->getCode()));
     }
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:15,代码来源:Edit.php


示例9: setCustomerGroupValue

 /**
  * Update customer group value
  * Method set group code instead id value
  * @return void
  */
 private function setCustomerGroupValue()
 {
     $value = $this->getData(self::$customerGroupAttributeCode);
     try {
         $group = $this->groupRepository->getById($value);
         $this->setCustomAttribute(self::$customerGroupAttributeCode, $group->getCode());
     } catch (NoSuchEntityException $e) {
         $this->setCustomAttribute(self::$customerGroupAttributeCode, 'N/A');
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Document.php


示例10: testGetDefaultRateRequest

 public function testGetDefaultRateRequest()
 {
     $customerDataSet = $this->customerRepository->getById(self::FIXTURE_CUSTOMER_ID);
     $address = $this->addressRepository->getById(self::FIXTURE_ADDRESS_ID);
     $rateRequest = $this->_model->getRateRequest(null, null, null, null, $customerDataSet->getId());
     $this->assertNotNull($rateRequest);
     $this->assertEquals($address->getCountryId(), $rateRequest->getCountryId());
     $this->assertEquals($address->getRegion()->getRegionId(), $rateRequest->getRegionId());
     $this->assertEquals($address->getPostcode(), $rateRequest->getPostcode());
     $customerTaxClassId = $this->groupRepository->getById($customerDataSet->getGroupId())->getTaxClassId();
     $this->assertEquals($customerTaxClassId, $rateRequest->getCustomerClassId());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:12,代码来源:CalculationTest.php


示例11: getMetadataValues

 /**
  * Get metadata for sales rule form. It will be merged with form UI component declaration.
  *
  * @param Rule $rule
  * @return array
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function getMetadataValues(\Magento\SalesRule\Model\Rule $rule)
 {
     $customerGroups = $this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems();
     $applyOptions = [['label' => __('Percent of product price discount'), 'value' => Rule::BY_PERCENT_ACTION], ['label' => __('Fixed amount discount'), 'value' => Rule::BY_FIXED_ACTION], ['label' => __('Fixed amount discount for whole cart'), 'value' => Rule::CART_FIXED_ACTION], ['label' => __('Buy X get Y free (discount amount is Y)'), 'value' => Rule::BUY_X_GET_Y_ACTION]];
     $couponTypesOptions = [];
     $couponTypes = $this->salesRuleFactory->create()->getCouponTypes();
     foreach ($couponTypes as $key => $couponType) {
         $couponTypesOptions[] = ['label' => $couponType, 'value' => $key];
     }
     $labels = $rule->getStoreLabels();
     return ['rule_information' => ['children' => ['website_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->store->getWebsiteValuesForForm()]]]], 'is_active' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Active'), 'value' => '1'], ['label' => __('Inactive'), 'value' => '0']]]]]], 'customer_group_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->objectConverter->toOptionArray($customerGroups, 'id', 'code')]]]], 'coupon_type' => ['arguments' => ['data' => ['config' => ['options' => $couponTypesOptions]]]], 'is_rss' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'actions' => ['children' => ['simple_action' => ['arguments' => ['data' => ['config' => ['options' => $applyOptions]]]], 'discount_amount' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'discount_qty' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'apply_to_shipping' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]], 'stop_rules_processing' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'labels' => ['children' => ['store_labels[0]' => ['arguments' => ['data' => ['config' => ['value' => isset($labels[0]) ? $labels[0] : '']]]]]]];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:ValueProvider.php


示例12: testPrepareDataSource

 public function testPrepareDataSource()
 {
     $itemName = 'itemName';
     $oldItemValue = 'oldItemValue';
     $newItemValue = 'newItemValue';
     $dataSource = ['data' => ['items' => [[$itemName => $oldItemValue]]]];
     $group = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\GroupInterface');
     $group->expects($this->once())->method('getCode')->willReturn($newItemValue);
     $this->groupRepository->expects($this->once())->method('getById')->with($oldItemValue)->willReturn($group);
     $this->model->setData('name', $itemName);
     $dataSource = $this->model->prepareDataSource($dataSource);
     $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:CustomerGroupTest.php


示例13: toOptionArray

 /**
  * Return array of customer groups
  *
  * @return array
  */
 public function toOptionArray()
 {
     if (!$this->moduleManager->isEnabled('Magento_Customer')) {
         return [];
     }
     $customerGroups = [['label' => __('ALL GROUPS'), 'value' => GroupInterface::CUST_GROUP_ALL]];
     /** @var GroupInterface[] $groups */
     $groups = $this->groupRepository->getList($this->searchCriteriaBuilder->create());
     foreach ($groups->getItems() as $group) {
         $customerGroups[] = ['label' => $group->getCode(), 'value' => $group->getId()];
     }
     return $customerGroups;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:Group.php


示例14: testDeleteButtonExistInCustomGroup

 /**
  * @magentoDataFixture Magento/Customer/_files/customer_group.php
  */
 public function testDeleteButtonExistInCustomGroup()
 {
     $builder = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\FilterBuilder');
     /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteria */
     $searchCriteria = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\SearchCriteriaBuilder')->addFilters([$builder->setField('code')->setValue('custom_group')->create()])->create();
     $customerGroup = $this->groupRepository->getList($searchCriteria)->getItems()[0];
     $this->getRequest()->setParam('id', $customerGroup->getId());
     $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId());
     /** @var $block Edit */
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Group\\Edit', 'block');
     $buttonsHtml = $block->getButtonsHtml();
     $this->assertContains('delete', $buttonsHtml);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:EditTest.php


示例15: testToOptionArray

 public function testToOptionArray()
 {
     $customerGroups = [['label' => __('ALL GROUPS'), 'value' => 32000], ['label' => __('NOT LOGGED IN'), 'value' => 0]];
     $this->moduleManagerMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $this->searchCriteriaBuilderMock->expects($this->any())->method('create')->willReturn($this->searchCriteriaMock);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultMock);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultMock);
     $groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass();
     $groupTest->expects($this->any())->method('getCode')->willReturn(__('NOT LOGGED IN'));
     $groupTest->expects($this->any())->method('getId')->willReturn(0);
     $groups = [$groupTest];
     $this->searchResultMock->expects($this->any())->method('getItems')->willReturn($groups);
     $this->assertEquals($customerGroups, $this->model->toOptionArray());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:GroupTest.php


示例16: _getCustomerGroups

 /**
  * Retrieve allowed customer groups
  *
  * @param int $groupId return name by customer group id
  * @return array|string
  */
 protected function _getCustomerGroups($groupId = null)
 {
     if ($this->_customerGroups === null) {
         $this->_customerGroups = [];
         foreach ($this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems() as $item) {
             $this->_customerGroups[$item->getId()] = $item->getCode();
         }
         $notLoggedInGroup = $this->groupManagement->getNotLoggedInGroup();
         $this->_customerGroups[$notLoggedInGroup->getId()] = $notLoggedInGroup->getCode();
     }
     if ($groupId !== null) {
         return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : null;
     }
     return $this->_customerGroups;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:Customergroup.php


示例17: prepareDataSource

 /**
  * Prepare Data Source
  *
  * @param array $dataSource
  * @return array
  */
 public function prepareDataSource(array $dataSource)
 {
     if (isset($dataSource['data']['items'])) {
         foreach ($dataSource['data']['items'] as &$item) {
             try {
                 $item[$this->getData('name')] = $this->groupRepository->getById($item[$this->getData('name')])->getCode();
             } catch (NoSuchEntityException $exception) {
                 $item[$this->getData('name')] = __('Group was removed');
             } catch (\Exception $exception) {
                 $item[$this->getData('name')] = '';
             }
         }
     }
     return $dataSource;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:CustomerGroup.php


示例18: testGetFormExistInCustomGroup

 /**
  * @magentoDataFixture Magento/Customer/_files/customer_group.php
  */
 public function testGetFormExistInCustomGroup()
 {
     $builder = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\FilterBuilder');
     /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteria */
     $searchCriteria = Bootstrap::getObjectManager()->create('Magento\\Framework\\Api\\SearchCriteriaBuilder')->addFilters([$builder->setField('code')->setValue('custom_group')->create()]);
     /** @var GroupInterface $customerGroup */
     $customerGroup = $this->groupRepository->getList($searchCriteria->create())->getItems()[0];
     $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId());
     /** @var $block Form */
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Group\\Edit\\Form', 'block');
     $form = $block->getForm();
     $this->assertEquals('edit_form', $form->getId());
     $this->assertEquals('post', $form->getMethod());
     $baseFieldSet = $form->getElement('base_fieldset');
     $this->assertNotNull($baseFieldSet);
     $groupCodeElement = $form->getElement('customer_group_code');
     $this->assertNotNull($groupCodeElement);
     $taxClassIdElement = $form->getElement('tax_class_id');
     $this->assertNotNull($taxClassIdElement);
     $idElement = $form->getElement('id');
     $this->assertNotNull($idElement);
     $this->assertEquals($customerGroup->getId(), $idElement->getValue());
     $this->assertEquals($customerGroup->getTaxClassId(), $taxClassIdElement->getValue());
     /** @var \Magento\Tax\Model\TaxClass\Source\Customer $taxClassCustomer */
     $taxClassCustomer = Bootstrap::getObjectManager()->get('Magento\\Tax\\Model\\TaxClass\\Source\\Customer');
     $this->assertEquals($taxClassCustomer->toOptionArray(false), $taxClassIdElement->getData('values'));
     $this->assertEquals($customerGroup->getCode(), $groupCodeElement->getValue());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:31,代码来源:FormTest.php


示例19: testSetAccountData

 public function testSetAccountData()
 {
     $taxClassId = 1;
     $attributes = [['email', '[email protected]'], ['group_id', 1]];
     $attributeMocks = [];
     foreach ($attributes as $attribute) {
         $attributeMock = $this->getMock('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], [], '', false);
         $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attribute[0]));
         $attributeMocks[] = $attributeMock;
     }
     $customerGroupMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\GroupInterface', [], '', false, true, true, ['getTaxClassId']);
     $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId));
     $customerFormMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $customerFormMock->expects($this->any())->method('getAttributes')->will($this->returnValue($attributeMocks));
     $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->getMock('Magento\\Framework\\App\\RequestInterface')));
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerMapper->expects($this->atLeastOnce())->method('toFlatArray')->willReturn(['email' => '[email protected]', 'group_id' => 1, 'gender' => 1]);
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
     $quoteMock->expects($this->once())->method('addData')->with(['customer_email' => $attributes[0][1], 'customer_group_id' => $attributes[1][1], 'customer_tax_class_id' => $taxClassId]);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($customerMock, ['email' => '[email protected]', 'group_id' => 1, 'gender' => 1], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
     $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerMock));
     $this->groupRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($customerGroupMock));
     $this->adminOrderCreate->setAccountData([]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:CreateTest.php


示例20: getLoggedInGroups

 /**
  * {@inheritdoc}
  */
 public function getLoggedInGroups()
 {
     $notLoggedInFilter[] = $this->filterBuilder->setField(GroupInterface::ID)->setConditionType('neq')->setValue(self::NOT_LOGGED_IN_ID)->create();
     $groupAll[] = $this->filterBuilder->setField(GroupInterface::ID)->setConditionType('neq')->setValue(self::CUST_GROUP_ALL)->create();
     $searchCriteria = $this->searchCriteriaBuilder->addFilters($notLoggedInFilter)->addFilters($groupAll)->create();
     return $this->groupRepository->getList($searchCriteria)->getItems();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:GroupManagement.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Data\CustomerInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Api\GroupManagementInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap