/** * @param string $sku * @return string[] */ public function getProductStatusMatchingSku($sku) { $this->validateSku($sku); $this->searchCriteriaBuilder->addFilter('sku', '%' . $sku . '%', 'like'); $result = $this->productRepository->getList($this->searchCriteriaBuilder->create()); return array_reduce($result->getItems(), function ($acc, ProductInterface $product) { return array_merge($acc, [$product->getSku() => $this->getStatusAsString($product)]); }, []); }
/** * {@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); }
/** * Load search results * * @return $this */ public function load() { $result = []; if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) { $this->setResults($result); return $this; } $this->searchCriteriaBuilder->setCurrentPage($this->getStart()); $this->searchCriteriaBuilder->setPageSize($this->getLimit()); $searchFields = ['firstname', 'lastname', 'company']; $filters = []; foreach ($searchFields as $field) { $filters[] = $this->filterBuilder->setField($field)->setConditionType('like')->setValue($this->getQuery() . '%')->create(); } $this->searchCriteriaBuilder->addFilters($filters); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchResults = $this->customerRepository->getList($searchCriteria); foreach ($searchResults->getItems() as $customer) { $customerAddresses = $customer->getAddresses(); /** Look for a company name defined in default billing address */ $company = null; foreach ($customerAddresses as $customerAddress) { if ($customerAddress->getId() == $customer->getDefaultBilling()) { $company = $customerAddress->getCompany(); break; } } $result[] = ['id' => 'customer/1/' . $customer->getId(), 'type' => __('Customer'), 'name' => $this->_customerViewHelper->getCustomerName($customer), 'description' => $company, 'url' => $this->_adminhtmlData->getUrl('customer/index/edit', ['id' => $customer->getId()])]; } $this->setResults($result); return $this; }
public function testGetByIdentifierNamespace() { $userId = 1; $namespace = 'some_namespace'; $identifier = 'current'; $this->userContext->expects($this->once())->method('getUserId')->willReturn($userId); $fieldUserId = new Filter([Filter::KEY_FIELD => 'user_id', Filter::KEY_VALUE => $userId, Filter::KEY_CONDITION_TYPE => 'eq']); $fieldIdentifier = new Filter([Filter::KEY_FIELD => 'identifier', Filter::KEY_VALUE => $identifier, Filter::KEY_CONDITION_TYPE => 'eq']); $fieldNamespace = new Filter([Filter::KEY_FIELD => 'namespace', Filter::KEY_VALUE => $namespace, Filter::KEY_CONDITION_TYPE => 'eq']); $bookmarkId = 1; $bookmark = $this->getMockBuilder('Magento\\Ui\\Api\\Data\\BookmarkInterface')->getMockForAbstractClass(); $bookmark->expects($this->once())->method('getId')->willReturn($bookmarkId); $searchCriteria = $this->getMockBuilder('Magento\\Framework\\Api\\SearchCriteriaInterface')->getMockForAbstractClass(); $this->filterBuilder->expects($this->at(0))->method('create')->willReturn($fieldUserId); $this->filterBuilder->expects($this->at(1))->method('create')->willReturn($fieldIdentifier); $this->filterBuilder->expects($this->at(2))->method('create')->willReturn($fieldNamespace); $this->searchCriteriaBuilder->expects($this->once())->method('addFilters')->with([$fieldUserId, $fieldIdentifier, $fieldNamespace]); $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); $searchResult = $this->getMockBuilder('Magento\\Ui\\Api\\Data\\BookmarkSearchResultsInterface')->getMockForAbstractClass(); $searchResult->expects($this->once())->method('getTotalCount')->willReturn(1); $searchResult->expects($this->once())->method('getItems')->willReturn([$bookmark]); $this->bookmarkRepository->expects($this->once())->method('getList')->with($searchCriteria)->willReturn($searchResult); $this->bookmarkRepository->expects($this->once())->method('getById')->with($bookmarkId)->willReturn($bookmark); $this->assertEquals($bookmark, $this->bookmarkManagement->getByIdentifierNamespace($identifier, $namespace)); }
/** * Run test getAllOptions method * * @param bool $isEmpty * @param array $expected * @dataProvider dataProviderGetAllOptions */ public function testGetAllOptions($isEmpty, array $expected) { $filterMock = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false); $searchCriteriaMock = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $searchResultsMock = $this->getMockForAbstractClass('Magento\\Tax\\Api\\Data\\TaxClassSearchResultsInterface', [], '', false, true, true, ['getItems']); $taxClassMock = $this->getMockForAbstractClass('Magento\\Tax\\Api\\Data\\TaxClassInterface', ['getClassId', 'getClassName'], '', false, true, true); $this->filterBuilderMock->expects($this->once())->method('setField')->with(\Magento\Tax\Model\ClassModel::KEY_TYPE)->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setValue')->with(\Magento\Tax\Api\TaxClassManagementInterface::TYPE_CUSTOMER)->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock])->willReturnSelf(); $this->searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); $this->taxClassRepositoryMock->expects($this->once())->method('getList')->with($searchCriteriaMock)->willReturn($searchResultsMock); if (!$isEmpty) { $taxClassMock->expects($this->once())->method('getClassId')->willReturn(10); $taxClassMock->expects($this->once())->method('getClassName')->willReturn('class-name'); $items = [$taxClassMock]; $searchResultsMock->expects($this->once())->method('getItems')->willReturn($items); // checking of a lack of re-initialization for ($i = 10; --$i;) { $result = $this->customer->getAllOptions(); $this->assertEquals($expected, $result); } } else { $items = []; $searchResultsMock->expects($this->once())->method('getItems')->willReturn($items); // checking exception $this->assertEmpty($this->customer->getAllOptions()); } }
public function testResolve() { $documentIds = [1, 2, 3]; $attributeSetIds = [4, 5]; $requestName = 'request_name'; $this->attributeSetFinder->expects($this->once())->method('findAttributeSetIdsByProductIds')->with($documentIds)->willReturn($attributeSetIds); $searchCriteria = $this->getMock(SearchCriteriaInterface::class); $this->searchCriteriaBuilder->expects($this->once())->method('addFilter')->with('attribute_set_id', $attributeSetIds, 'in')->willReturnSelf(); $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); $attributeFirst = $this->getMock(ProductAttributeInterface::class); $attributeFirst->expects($this->once())->method('getAttributeCode')->willReturn('code_1'); $attributeSecond = $this->getMock(ProductAttributeInterface::class); $attributeSecond->expects($this->once())->method('getAttributeCode')->willReturn('code_2'); $searchResult = $this->getMock(ProductAttributeSearchResultsInterface::class); $searchResult->expects($this->once())->method('getItems')->willReturn([$attributeFirst, $attributeSecond]); $this->productAttributeRepository->expects($this->once())->method('getList')->with($searchCriteria)->willReturn($searchResult); $bucketFirst = $this->getMock(BucketInterface::class); $bucketFirst->expects($this->once())->method('getField')->willReturn('code_1'); $bucketSecond = $this->getMock(BucketInterface::class); $bucketSecond->expects($this->once())->method('getField')->willReturn('some_another_code'); $bucketThird = $this->getMock(BucketInterface::class); $bucketThird->expects($this->once())->method('getName')->willReturn('custom_not_attribute_field'); $this->request->expects($this->once())->method('getAggregation')->willReturn([$bucketFirst, $bucketSecond, $bucketThird]); $this->request->expects($this->once())->method('getName')->willReturn($requestName); $this->config->expects($this->once())->method('get')->with($requestName)->willReturn(['aggregations' => ['custom_not_attribute_field' => []]]); $this->assertEquals([$bucketFirst, $bucketThird], $this->aggregationResolver->resolve($this->request, $documentIds)); }
/** * {@inheritdoc} */ public function init($context) { foreach ($this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems() as $group) { $this->customerGroups[$group->getId()] = true; } return parent::init($context); }
/** * {@inheritdoc} */ public function getData(array $fieldsData) { $service = $this->getService(); $searchCriteria = $this->searchCriteriaBuilder->create(); /** @var SearchResults $list */ $list = $service->getList($searchCriteria); return $this->getRequestedFields($list, $fieldsData); }
/** * Retrieve all tax rates as an options array. * * @return array */ public function toOptionArray() { if (!$this->options) { $searchCriteria = $this->searchCriteriaBuilder->create(); $searchResults = $this->taxRateRepository->getList($searchCriteria); $this->options = $this->converter->toOptionArray($searchResults->getItems(), Rate::KEY_ID, Rate::KEY_CODE); } return $this->options; }
/** * Retrieve all tax rates as an options array. * * @return array */ public function toOptionArray() { if (!$this->options) { $searchCriteria = $this->searchCriteriaBuilder->create(); $searchResults = $this->sliderRepository->getList($searchCriteria); $this->options = $this->converter->toOptionArray($searchResults->getItems(), Slider::ID, Slider::SLIDER_TITLE); } return $this->options; }
/** * @param string $sku * @return string[] */ public function getStatusForProductsMatchingSku($sku) { $this->validateSku($sku); $this->searchCriteriaBuilder->addFilter('sku', $this->getLikeSkuExpression($sku), 'like'); $productList = $this->productRepository->getList($this->searchCriteriaBuilder->create()); return array_reduce($productList->getItems(), function (array $carry, ProductInterface $product) { return array_merge($carry, [$product->getSku() => $this->getStatusString($product)]); }, []); }
protected function setUp() { $this->groupRepositoryInterface = $this->getMock('Magento\\Customer\\Model\\ResourceModel\\GroupRepository', [], [], '', false); $this->searchCriteriaSearch = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $this->searchCriteriaBuilder = $this->getMock('Magento\\Framework\\Api\\SearchCriteriaBuilder', [], [], '', false); $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($this->searchCriteriaSearch); $this->storeResolver = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product\\StoreResolver', [], [], '', false); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->tierPrice = $this->objectManagerHelper->getObject('Magento\\CatalogImportExport\\Model\\Import\\Product\\Validator\\TierPrice', ['groupRepository' => $this->groupRepositoryInterface, 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, 'storeResolver' => $this->storeResolver]); }
public function testGetCommentsList() { $this->filterBuilderMock->expects($this->once())->method('setField')->with('parent_id')->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setValue')->with(123)->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($this->filterMock); $this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->with(['eq' => $this->filterMock])->willReturn($this->filterBuilderMock); $this->searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($this->searchCriteriaMock); $this->orderStatusHistoryRepositoryMock->expects($this->once())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->orderSearchResultMock); $this->assertEquals($this->orderSearchResultMock, $this->orderService->getCommentsList(123)); }
public function testGetFeeds() { $feeds = ['feed1', 'feed2']; $searchCriteria = $this->getMockBuilder('\\Magento\\Framework\\Api\\SearchCriteria')->disableOriginalConstructor()->getMock(); $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); $searchResult = $this->getMockBuilder('\\Magento\\SampleServiceContractNew\\API\\Data\\FeedSearchResultInterface')->disableOriginalConstructor()->getMockForAbstractClass(); $searchResult->expects($this->once())->method('getItems')->willReturn($feeds); $this->feedRepository->expects($this->once())->method('getList')->willReturn($searchResult); $this->assertEquals($feeds, $this->block->getFeeds()); }
/** * Returns array of fields * * @param string $entityType * @return array * @throws \Exception */ public function getAttributes($entityType) { $metadata = $this->metadataPool->getMetadata($entityType); $searchResult = $this->attributeRepository->getList($metadata->getEavEntityType(), $this->searchCriteriaBuilder->create()); $attributes = []; foreach ($searchResult->getItems() as $attribute) { $attributes[] = $attribute->getAttributeCode(); } return $attributes; }
/** * Get applicable attributes * * @param array $documentIds * @return array */ private function getApplicableAttributeCodes(array $documentIds) { $attributeSetIds = $this->attributeSetFinder->findAttributeSetIdsByProductIds($documentIds); $searchCriteria = $this->searchCriteriaBuilder->addFilter('attribute_set_id', $attributeSetIds, 'in')->create(); $result = $this->productAttributeRepository->getList($searchCriteria); $attributeCodes = []; foreach ($result->getItems() as $attribute) { $attributeCodes[] = $attribute->getAttributeCode(); } return $attributeCodes; }
/** * 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] : '']]]]]]]; }
/** * @return void */ public function execute() { $filter = $this->filterBuilder->setField('parent_id')->setValue($this->_getCheckout()->getCustomer()->getId())->setConditionType('eq')->create(); $addresses = (array) $this->addressRepository->getList($this->searchCriteriaBuilder->addFilters([$filter])->create())->getItems(); /** * if we create first address we need reset emd init checkout */ if (count($addresses) === 1) { $this->_getCheckout()->reset(); } $this->_redirect('*/checkout/addresses'); }
/** * @param string $entityType * @return \Magento\Eav\Api\Data\AttributeInterface[] * @throws \Exception */ protected function getAttributes($entityType) { $attributes = $this->attributeCache->getAttributes($entityType); if ($attributes) { return $attributes; } $metadata = $this->metadataPool->getMetadata($entityType); $searchResult = $this->attributeRepository->getList($metadata->getEavEntityType(), $this->searchCriteriaBuilder->create()); $attributes = $searchResult->getItems(); $this->attributeCache->saveAttributes($entityType, $attributes); return $attributes; }
/** * 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; }
/** * {@inheritdoc} */ public function getByIdentifierNamespace($identifier, $namespace) { $this->searchCriteriaBuilder->addFilters([$this->filterBuilder->setField('user_id')->setConditionType('eq')->setValue($this->userContext->getUserId())->create(), $this->filterBuilder->setField('identifier')->setConditionType('eq')->setValue($identifier)->create(), $this->filterBuilder->setField('namespace')->setConditionType('eq')->setValue($namespace)->create()]); $searchCriteria = $this->searchCriteriaBuilder->create(); $searchResults = $this->bookmarkRepository->getList($searchCriteria); if ($searchResults->getTotalCount() > 0) { foreach ($searchResults->getItems() as $searchResult) { $bookmark = $this->bookmarkRepository->getById($searchResult->getId()); return $bookmark; } } return null; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // Get list of available records $searchCriteria = $this->searchCriteriaBuilder->create(); $searchResult = $this->demoRepository->getList($searchCriteria); $rows = []; foreach ($searchResult->getItems() as $item) { $rows[] = [$item->getId(), $item->getTitle()]; } $table = $this->getHelper('table'); $table->setHeaders(array(__('ID'), __('Title')))->setRows($rows); $table->render($output); }
/** * Run test getCommentsList method */ public function testGetCommentsList() { $id = 25; $returnValue = 'return-value'; $filterMock = $this->getMock('Magento\\Framework\\Api\\Filter', [], [], '', false); $searchCriteriaMock = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false); $this->filterBuilderMock->expects($this->once())->method('setField')->with('parent_id')->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once())->method('setValue')->with($id)->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once())->method('create')->will($this->returnValue($filterMock)); $this->criteriaBuilderMock->expects($this->once())->method('addFilter')->with(['eq' => $filterMock]); $this->criteriaBuilderMock->expects($this->once())->method('create')->will($this->returnValue($searchCriteriaMock)); $this->commentRepositoryMock->expects($this->once())->method('getList')->with($searchCriteriaMock)->will($this->returnValue($returnValue)); $this->assertEquals($returnValue, $this->shipmentService->getCommentsList($id)); }
/** * Get a list of current customer addresses. * * @return \Magento\Customer\Api\Data\AddressInterface[] */ public function getAddress() { $addresses = $this->getData('address_collection'); if ($addresses === null) { try { $filter = $this->filterBuilder->setField('parent_id')->setValue($this->_multishipping->getCustomer()->getId())->setConditionType('eq')->create(); $addresses = (array) $this->addressRepository->getList($this->searchCriteriaBuilder->addFilters([$filter])->create())->getItems(); } catch (NoSuchEntityException $e) { return []; } $this->setData('address_collection', $addresses); } return $addresses; }
/** * Retrieve all customer tax classes as an options array. * * @return array * @throws StateException */ public function getAllOptions() { if (empty($this->_options)) { $options = []; $filter = $this->filterBuilder->setField(TaxClass::KEY_TYPE)->setValue(TaxClassManagementInterface::TYPE_CUSTOMER)->create(); $searchCriteria = $this->searchCriteriaBuilder->addFilter([$filter])->create(); $searchResults = $this->taxClassRepository->getList($searchCriteria); foreach ($searchResults->getItems() as $taxClass) { $options[] = ['value' => $taxClass->getClassId(), 'label' => $taxClass->getClassName()]; } $this->_options = $options; } return $this->_options; }
protected function setUp() { $this->contextMock = $this->getMockBuilder(ContextInterface::class)->getMockForAbstractClass(); $this->attributeRepositoryMock = $this->getMockBuilder(ProductAttributeRepositoryInterface::class)->getMockForAbstractClass(); $this->searchCriteriaBuilderMock = $this->getMockBuilder(SearchCriteriaBuilder::class)->disableOriginalConstructor()->getMock(); $this->uiElementProcessorMock = $this->getMockBuilder(UiElementProcessor::class)->disableOriginalConstructor()->getMock(); $this->searchCriteriaMock = $this->getMockBuilder(SearchCriteria::class)->disableOriginalConstructor()->getMock(); $this->searchResultsMock = $this->getMockBuilder(ProductAttributeSearchResultsInterface::class)->getMockForAbstractClass(); $this->contextMock->expects(static::any())->method('getProcessor')->willReturn($this->uiElementProcessorMock); $this->searchCriteriaBuilderMock->expects(static::any())->method('addFilter')->willReturnSelf(); $this->searchCriteriaBuilderMock->expects(static::any())->method('create')->willReturn($this->searchCriteriaMock); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->attributesColumn = $this->objectManagerHelper->getObject(AttributesColumn::class, ['context' => $this->contextMock, 'attributeRepository' => $this->attributeRepositoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock]); }
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()); }
/** * 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; }
/** * @param CustomerInterface $entity * @return CustomerInterface * @throws \Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute($entity, $arguments = []) { $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $entity->getId())->create(); $addressesResult = $this->addressRepository->getList($searchCriteria); $entity->setAddresses($addressesResult->getItems()); return $entity; }
/** * {@inheritdoc} */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { $this->searchCriteriaBuilder->addFilter([$this->filterBuilder->setField('entity_type_code')->setValue(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)->setConditionType('eq')->create()]); $this->searchCriteriaBuilder->setCurrentPage($searchCriteria->getCurrentPage()); $this->searchCriteriaBuilder->setPageSize($searchCriteria->getPageSize()); return $this->attributeSetRepository->getList($this->searchCriteriaBuilder->create()); }