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


PHP Api\GroupRepositoryInterface类代码示例

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


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


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