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


PHP GroupRepositoryInterface::getList方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: _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

示例7: 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

示例8: 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

示例9: loadData

 /**
  * Load customer group collection data from service
  *
  * @param bool $printQuery
  * @param bool $logQuery
  * @return $this
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function loadData($printQuery = false, $logQuery = false)
 {
     if (!$this->isLoaded()) {
         $searchCriteria = $this->getSearchCriteria();
         $searchResults = $this->groupRepository->getList($searchCriteria);
         $this->_totalRecords = $searchResults->getTotalCount();
         /** @var GroupInterface[] $groups */
         $groups = $searchResults->getItems();
         foreach ($groups as $group) {
             $groupItem = new \Magento\Framework\DataObject();
             $groupItem->addData($this->simpleDataObjectConverter->toFlatArray($group, '\\Magento\\Customer\\Api\\Data\\GroupInterface'));
             $this->_addItem($groupItem);
         }
         $this->_setIsLoaded();
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:ServiceCollection.php

示例10: _prepareForm

 /**
  * Prepare form before rendering HTML
  *
  * @return $this
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     $model = $this->_coreRegistry->registry('current_promo_quote_rule');
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('rule_');
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information')]);
     if ($model->getId()) {
         $fieldset->addField('rule_id', 'hidden', ['name' => 'rule_id']);
     }
     $fieldset->addField('product_ids', 'hidden', ['name' => 'product_ids']);
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Rule Name'), 'title' => __('Rule Name'), 'required' => true]);
     $fieldset->addField('description', 'textarea', ['name' => 'description', 'label' => __('Description'), 'title' => __('Description'), 'style' => 'height: 100px;']);
     $fieldset->addField('is_active', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Active'), '0' => __('Inactive')]]);
     if (!$model->getId()) {
         $model->setData('is_active', '1');
     }
     if ($this->_storeManager->isSingleStoreMode()) {
         $websiteId = $this->_storeManager->getStore(true)->getWebsiteId();
         $fieldset->addField('website_ids', 'hidden', ['name' => 'website_ids[]', 'value' => $websiteId]);
         $model->setWebsiteIds($websiteId);
     } else {
         $field = $fieldset->addField('website_ids', 'multiselect', ['name' => 'website_ids[]', 'label' => __('Websites'), 'title' => __('Websites'), 'required' => true, 'values' => $this->_systemStore->getWebsiteValuesForForm()]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     }
     $groups = $this->groupRepository->getList($this->_searchCriteriaBuilder->create())->getItems();
     $fieldset->addField('customer_group_ids', 'multiselect', ['name' => 'customer_group_ids[]', 'label' => __('Customer Groups'), 'title' => __('Customer Groups'), 'required' => true, 'values' => $this->_objectConverter->toOptionArray($groups, 'id', 'code')]);
     $couponTypeFiled = $fieldset->addField('coupon_type', 'select', ['name' => 'coupon_type', 'label' => __('Coupon'), 'required' => true, 'options' => $this->_salesRule->create()->getCouponTypes()]);
     $couponCodeFiled = $fieldset->addField('coupon_code', 'text', ['name' => 'coupon_code', 'label' => __('Coupon Code'), 'required' => true]);
     $autoGenerationCheckbox = $fieldset->addField('use_auto_generation', 'checkbox', ['name' => 'use_auto_generation', 'label' => __('Use Auto Generation'), 'note' => __('If you select and save the rule you will be able to generate multiple coupon codes.'), 'onclick' => 'handleCouponsTabContentActivity()', 'checked' => (int) $model->getUseAutoGeneration() > 0 ? 'checked' : '']);
     $autoGenerationCheckbox->setRenderer($this->getLayout()->createBlock('Magento\\SalesRule\\Block\\Adminhtml\\Promo\\Quote\\Edit\\Tab\\Main\\Renderer\\Checkbox'));
     $usesPerCouponFiled = $fieldset->addField('uses_per_coupon', 'text', ['name' => 'uses_per_coupon', 'label' => __('Uses per Coupon')]);
     $fieldset->addField('uses_per_customer', 'text', ['name' => 'uses_per_customer', 'label' => __('Uses per Customer'), 'note' => __('Usage limit enforced for logged in customers only.')]);
     $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
     $fieldset->addField('from_date', 'date', ['name' => 'from_date', 'label' => __('From'), 'title' => __('From'), 'input_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT, 'date_format' => $dateFormat]);
     $fieldset->addField('to_date', 'date', ['name' => 'to_date', 'label' => __('To'), 'title' => __('To'), 'input_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT, 'date_format' => $dateFormat]);
     $fieldset->addField('sort_order', 'text', ['name' => 'sort_order', 'label' => __('Priority')]);
     $fieldset->addField('is_rss', 'select', ['label' => __('Public In RSS Feed'), 'title' => __('Public In RSS Feed'), 'name' => 'is_rss', 'options' => ['1' => __('Yes'), '0' => __('No')]]);
     if (!$model->getId()) {
         //set the default value for is_rss feed to yes for new promotion
         $model->setIsRss(1);
     }
     $form->setValues($model->getData());
     $autoGenerationCheckbox->setValue(1);
     if ($model->isReadonly()) {
         foreach ($fieldset->getElements() as $element) {
             $element->setReadonly(true, true);
         }
     }
     //$form->setUseContainer(true);
     $this->setForm($form);
     // field dependencies
     $this->setChild('form_after', $this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Form\\Element\\Dependence')->addFieldMap($couponTypeFiled->getHtmlId(), $couponTypeFiled->getName())->addFieldMap($couponCodeFiled->getHtmlId(), $couponCodeFiled->getName())->addFieldMap($autoGenerationCheckbox->getHtmlId(), $autoGenerationCheckbox->getName())->addFieldMap($usesPerCouponFiled->getHtmlId(), $usesPerCouponFiled->getName())->addFieldDependence($couponCodeFiled->getName(), $couponTypeFiled->getName(), \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC)->addFieldDependence($autoGenerationCheckbox->getName(), $couponTypeFiled->getName(), \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC)->addFieldDependence($usesPerCouponFiled->getName(), $couponTypeFiled->getName(), \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC));
     $this->_eventManager->dispatch('adminhtml_promo_quote_edit_tab_main_prepare_form', ['form' => $form]);
     return parent::_prepareForm();
 }
开发者ID:kid17,项目名称:magento2,代码行数:64,代码来源:Main.php

示例11: _loadCustomerGroups

 private function _loadCustomerGroups()
 {
     $crit = $this->_builderSearchCriteria->create();
     $crit->setSortOrders(null);
     $all = $this->_repoCustomerGroup->getList($crit);
     /** @var \Magento\Customer\Model\Data\Group $item */
     foreach ($all->getItems() as $item) {
         $this->_custGroups[] = $item->getId();
     }
 }
开发者ID:praxigento,项目名称:mobi_app_generic_mage2,代码行数:10,代码来源:SalesRules.php

示例12: findGroupIdWithCode

 /**
  * Find the group with a given code.
  *
  * @param string $code
  * @return int
  */
 protected function findGroupIdWithCode($code)
 {
     /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */
     $searchBuilder = $this->_objectManager->create('Magento\\Framework\\Api\\SearchCriteriaBuilder');
     foreach ($this->groupRepository->getList($searchBuilder->create())->getItems() as $group) {
         if ($group->getCode() === $code) {
             return $group->getId();
         }
     }
     return -1;
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:17,代码来源:GroupTest.php

示例13: testGetList

 /**
  * @param array $filters
  * @param array $filterGroup
  * @param array $expectedResult array of expected results indexed by ID
  *
  * @dataProvider searchGroupsDataProvider
  */
 public function testGetList($filters, $filterGroup, $expectedResult)
 {
     foreach ($filters as $filter) {
         $this->searchCriteriaBuilder->addFilter([$filter]);
     }
     if ($filterGroup !== null) {
         $this->searchCriteriaBuilder->addFilter($filterGroup);
     }
     $searchResults = $this->groupRepository->getList($this->searchCriteriaBuilder->create());
     /** @var $item GroupInterface */
     foreach ($searchResults->getItems() as $item) {
         $this->assertEquals($expectedResult[$item->getId()][GroupInterface::CODE], $item->getCode());
         $this->assertEquals($expectedResult[$item->getId()][GroupInterface::TAX_CLASS_ID], $item->getTaxClassId());
         unset($expectedResult[$item->getId()]);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:23,代码来源:GroupRepositoryTest.php

示例14: testGetListSortOrder

 /**
  * @param string $field
  * @param string, $direction
  * @param string, $methodName
  * @param array $expectedResult
  *
  * @dataProvider sortOrderDataProvider
  */
 public function testGetListSortOrder($field, $direction, $methodName, $expectedResult)
 {
     /** @var \Magento\Framework\Api\SortOrder $sortOrder */
     /** @var string $direction */
     $direction = $direction == 'ASC' ? SearchCriteria::SORT_ASC : SearchCriteria::SORT_DESC;
     $sortOrder = $this->sortOrderBuilder->setField($field)->setDirection($direction)->create();
     $this->searchCriteriaBuilder->addSortOrder($sortOrder);
     $searchResults = $this->groupRepository->getList($this->searchCriteriaBuilder->create());
     /** @var \Magento\Customer\Api\Data\GroupInterface[] $resultItems */
     $resultItems = $searchResults->getItems();
     $this->assertTrue(count($resultItems) > 0);
     $result = [];
     foreach ($resultItems as $item) {
         /** @var \Magento\Customer\Model\Data\Group $item */
         $result[] = $item->{$methodName}();
     }
     $this->assertEquals($expectedResult, $result);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:26,代码来源:GroupRepositoryTest.php

示例15: getCustomerGroups

 /**
  * Retrieve allowed customer groups
  *
  * @param int|null $groupId  return name by customer group id
  * @return array|string
  */
 public function getCustomerGroups($groupId = null)
 {
     if ($this->_customerGroups === null) {
         if (!$this->moduleManager->isEnabled('Magento_Customer')) {
             return [];
         }
         $this->_customerGroups = $this->_getInitialCustomerGroups();
         /** @var \Magento\Customer\Api\Data\GroupInterface[] $groups */
         $groups = $this->_groupRepository->getList($this->_searchCriteriaBuilder->create());
         foreach ($groups->getItems() as $group) {
             $this->_customerGroups[$group->getId()] = $group->getCode();
         }
     }
     if ($groupId !== null) {
         return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : [];
     }
     return $this->_customerGroups;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:24,代码来源:AbstractGroup.php


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