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

PHP Api\FilterBuilder类代码示例

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

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



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

示例1: _renderFiltersBefore

 /**
  * @inheritdoc
  */
 protected function _renderFiltersBefore()
 {
     $this->getSearchCriteriaBuilder();
     $this->getFilterBuilder();
     $this->getSearch();
     if ($this->queryText) {
         $this->filterBuilder->setField('search_term');
         $this->filterBuilder->setValue($this->queryText);
         $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
     }
     $priceRangeCalculation = $this->_scopeConfig->getValue(\Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if ($priceRangeCalculation) {
         $this->filterBuilder->setField('price_dynamic_algorithm');
         $this->filterBuilder->setValue($priceRangeCalculation);
         $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());
     }
     $searchCriteria = $this->searchCriteriaBuilder->create();
     $searchCriteria->setRequestName($this->searchRequestName);
     $this->searchResult = $this->search->search($searchCriteria);
     $temporaryStorage = $this->temporaryStorageFactory->create();
     $table = $temporaryStorage->storeApiDocuments($this->searchResult->getItems());
     $this->getSelect()->joinInner(['search_result' => $table->getName()], 'e.entity_id = search_result.' . TemporaryStorage::FIELD_ENTITY_ID, []);
     $this->_totalRecords = $this->searchResult->getTotalCount();
     if ($this->order && 'relevance' === $this->order['field']) {
         $this->getSelect()->order('search_result.' . TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
     }
     return parent::_renderFiltersBefore();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:31,代码来源:Collection.php


示例2: load

 /**
  * 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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:37,代码来源:Customer.php


示例3: testLike

 /**
  * Test a search using 'like' condition
  */
 public function testLike()
 {
     $attributeCode = 'description';
     $attributeCodeId = 42;
     $attribute = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $attribute->expects($this->once())->method('getAttributeCode')->willReturn($attributeCode);
     $this->eavConfig->expects($this->once())->method('getAttribute')->with(Product::ENTITY, $attributeCodeId)->willReturn($attribute);
     $filtersData = ['catalog_product_entity_text' => [$attributeCodeId => ['like' => 'search text']]];
     $this->filterBuilder->expects($this->once())->method('setField')->with($attributeCode)->willReturn($this->filterBuilder);
     $this->filterBuilder->expects($this->once())->method('setValue')->with('search text')->willReturn($this->filterBuilder);
     $filter = $this->getMock('Magento\\Framework\\Api\\Filter');
     $this->filterBuilder->expects($this->once())->method('create')->willReturn($filter);
     $criteria = $this->getMock('Magento\\Framework\\Api\\Search\\SearchCriteria', [], [], '', false);
     $this->criteriaBuilder->expects($this->once())->method('create')->willReturn($criteria);
     $criteria->expects($this->once())->method('setRequestName')->with('advanced_search_container');
     $tempTable = $this->getMock('Magento\\Framework\\DB\\Ddl\\Table', [], [], '', false);
     $temporaryStorage = $this->getMock('Magento\\Framework\\Search\\Adapter\\Mysql\\TemporaryStorage', [], [], '', false);
     $temporaryStorage->expects($this->once())->method('storeApiDocuments')->willReturn($tempTable);
     $this->temporaryStorageFactory->expects($this->once())->method('create')->willReturn($temporaryStorage);
     $searchResult = $this->getMock('Magento\\Framework\\Api\\Search\\SearchResultInterface', [], [], '', false);
     $this->search->expects($this->once())->method('search')->willReturn($searchResult);
     // addFieldsToFilter will load filters,
     //   then loadWithFilter will trigger _renderFiltersBefore code in Advanced/Collection
     $this->assertSame($this->advancedCollection, $this->advancedCollection->addFieldsToFilter($filtersData)->loadWithFilter());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:28,代码来源:CollectionTest.php


示例4: testGetByIdentifierNamespace

 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));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:25,代码来源:BookmarkManagementTest.php


示例5: testGetAllOptions

 /**
  * 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());
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:36,代码来源:CustomerTest.php


示例6: testPrepare

 /**
  * Run test prepare method
  *
  * @param array $data
  * @param array $filterData
  * @param array|null $expectedCondition
  * @dataProvider getPrepareDataProvider
  * @return void
  */
 public function testPrepare($data, $filterData, $expectedCondition)
 {
     $name = $data['name'];
     /** @var UiComponentInterface $uiComponent */
     $uiComponent = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponentInterface', [], '', false);
     $uiComponent->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn(Select::NAME);
     $this->contextMock->expects($this->any())->method('addComponentDefinition')->with(Select::NAME, ['extends' => Select::NAME]);
     $this->contextMock->expects($this->any())->method('getFiltersParams')->willReturn($filterData);
     /** @var DataProviderInterface $dataProvider */
     $dataProvider = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProviderInterface', ['addFilter'], '', false);
     $this->contextMock->expects($this->any())->method('getDataProvider')->willReturn($dataProvider);
     if ($expectedCondition !== null) {
         $filterMock = $this->getMock('Magento\\Framework\\Api\\Filter');
         $this->filterBuilderMock->expects($this->any())->method('setConditionType')->with($expectedCondition)->willReturnSelf();
         $this->filterBuilderMock->expects($this->any())->method('setField')->with($name)->willReturnSelf();
         $this->filterBuilderMock->expects($this->any())->method('setValue')->willReturnSelf();
         $this->filterBuilderMock->expects($this->any())->method('create')->willReturn($filterMock);
         $dataProvider->expects($this->any())->method('addFilter')->with($filterMock);
     }
     /** @var \Magento\Framework\Data\OptionSourceInterface $selectOptions */
     $selectOptions = $this->getMockForAbstractClass('Magento\\Framework\\Data\\OptionSourceInterface', [], '', false);
     $this->uiComponentFactory->expects($this->any())->method('create')->with($name, Select::COMPONENT, ['context' => $this->contextMock, 'options' => $selectOptions])->willReturn($uiComponent);
     $date = new Select($this->contextMock, $this->uiComponentFactory, $this->filterBuilderMock, $this->filterModifierMock, $selectOptions, [], $data);
     $date->prepare();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:SelectTest.php


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


示例8: testApplyFilterModifierWith

 /**
  * @param $filterModifier
  * @param $filterName
  * @param $conditionType
  * @param $value
  * @return void
  * @dataProvider getApplyFilterModifierDataProvider
  */
 public function testApplyFilterModifierWith($filterModifier, $filterName, $conditionType, $value)
 {
     $filter = $this->getMock('Magento\\Framework\\Api\\Filter');
     $this->request->expects($this->once())->method('getParam')->with(\Magento\Ui\Component\Filters\FilterModifier::FILTER_MODIFIER)->willReturn($filterModifier);
     $this->filterBuilder->expects($this->once())->method('setConditionType')->with($conditionType)->willReturnSelf();
     $this->filterBuilder->expects($this->once())->method('setField')->with($filterName)->willReturnSelf();
     $this->filterBuilder->expects($this->once())->method('setValue')->with($value)->willReturnSelf();
     $this->filterBuilder->expects($this->once())->method('create')->with()->willReturn($filter);
     $this->dataProvider->expects($this->once())->method('addFilter')->with($filter);
     $this->unit->applyFilterModifier($this->dataProvider, $filterName);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:FilterModifierTest.php


示例9: execute

 /**
  * @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');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ShippingSaved.php


示例10: applyFilterModifier

 /**
  * Apply modifiers for filters
  *
  * @param DataProviderInterface $dataProvider
  * @param string $filterName
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function applyFilterModifier(DataProviderInterface $dataProvider, $filterName)
 {
     $filterModifier = $this->request->getParam(self::FILTER_MODIFIER);
     if (isset($filterModifier[$filterName]['condition_type'])) {
         $conditionType = $filterModifier[$filterName]['condition_type'];
         if (!in_array($conditionType, $this->allowedConditionTypes)) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Condition type "%1" is not allowed', $conditionType));
         }
         $value = isset($filterModifier[$filterName]['value']) ? $filterModifier[$filterName]['value'] : null;
         $filter = $this->filterBuilder->setConditionType($conditionType)->setField($filterName)->setValue($value)->create();
         $dataProvider->addFilter($filter);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:FilterModifier.php


示例11: getByIdentifierNamespace

 /**
  * {@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;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:BookmarkManagement.php


示例12: getAddress

 /**
  * 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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Select.php


示例13: getAllOptions

 /**
  * 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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:Customer.php


示例14: getDataSourceData

 /**
  * {@inheritdoc}
  */
 public function getDataSourceData()
 {
     $dataSource = [];
     $id = $this->getContext()->getRequestParam($this->getContext()->getDataProvider()->getRequestFieldName());
     if ($id) {
         $filter = $this->filterBuilder->setField($this->getContext()->getDataProvider()->getPrimaryFieldName())->setValue($id)->create();
         $this->getContext()->getDataProvider()->addFilter($filter);
         $data = $this->getContext()->getDataProvider()->getData();
         if (isset($data[$id])) {
             $dataSource = ['data' => $data[$id]];
         }
     }
     return $dataSource;
 }
开发者ID:vv-team,项目名称:foodo,代码行数:17,代码来源:Form.php


示例15: getTaxClassId

 /**
  * {@inheritdoc}
  */
 public function getTaxClassId($taxClassKey, $taxClassType = self::TYPE_PRODUCT)
 {
     if (!empty($taxClassKey)) {
         switch ($taxClassKey->getType()) {
             case TaxClassKeyInterface::TYPE_ID:
                 return $taxClassKey->getValue();
             case TaxClassKeyInterface::TYPE_NAME:
                 $searchCriteria = $this->searchCriteriaBuilder->addFilters([$this->filterBuilder->setField(ClassModel::KEY_TYPE)->setValue($taxClassType)->create()])->addFilters([$this->filterBuilder->setField(ClassModel::KEY_NAME)->setValue($taxClassKey->getValue())->create()])->create();
                 $taxClasses = $this->classRepository->getList($searchCriteria)->getItems();
                 $taxClass = array_shift($taxClasses);
                 return null == $taxClass ? null : $taxClass->getClassId();
         }
     }
     return null;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Management.php


示例16: get

 /**
  * load entity
  *
  * @param int $id
  * @return Transaction
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  * @throws \Magento\Framework\Exception\InputException
  */
 public function get($id)
 {
     if (!$id) {
         throw new \Magento\Framework\Exception\InputException(__('ID required'));
     }
     if (!isset($this->registry[$id])) {
         $filter = $this->filterBuilder->setField('transaction_id')->setValue($id)->setConditionType('eq')->create();
         $this->searchCriteriaBuilder->addFilters([$filter]);
         $this->find($this->searchCriteriaBuilder->create());
         if (!isset($this->registry[$id])) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'));
         }
     }
     return $this->registry[$id];
 }
开发者ID:nja78,项目名称:magento2,代码行数:23,代码来源:TransactionRepository.php


示例17: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing taxes:');
     $fixtureFile = 'Tax/tax_rate.csv';
     $fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
     /** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
     $csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
     foreach ($csvReader as $data) {
         if ($this->rateFactory->create()->loadByCode($data['code'])->getId()) {
             continue;
         }
         $taxRate = $this->rateFactory->create();
         $taxRate->setCode($data['code'])->setTaxCountryId($data['tax_country_id'])->setTaxRegionId($data['tax_region_id'])->setTaxPostcode($data['tax_postcode'])->setRate($data['rate']);
         $this->taxRateRepository->save($taxRate);
         $this->logger->logInline('.');
     }
     $fixtureFile = 'Tax/tax_rule.csv';
     $fixtureFilePath = $this->fixtureHelper->getPath($fixtureFile);
     /** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
     $csvReader = $this->csvReaderFactory->create(['fileName' => $fixtureFilePath, 'mode' => 'r']);
     foreach ($csvReader as $data) {
         $filter = $this->filterBuilder->setField('code')->setConditionType('=')->setValue($data['code'])->create();
         $criteria = $this->criteriaBuilder->addFilters([$filter])->create();
         $existingRates = $this->taxRuleRepository->getList($criteria)->getItems();
         if (!empty($existingRates)) {
             continue;
         }
         $taxRate = $this->taxRateFactory->create()->loadByCode($data['tax_rate']);
         $taxRule = $this->ruleFactory->create();
         $taxRule->setCode($data['code'])->setTaxRateIds([$taxRate->getId()])->setCustomerTaxClassIds([$data['tax_customer_class']])->setProductTaxClassIds([$data['tax_product_class']])->setPriority($data['priority'])->setCalculateSubtotal($data['calculate_subtotal'])->setPosition($data['position']);
         $this->taxRuleRepository->save($taxRule);
         $this->logger->logInline('.');
     }
 }
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:37,代码来源:Tax.php


示例18: getTokensComponents

 /**
  * @param string $vaultPaymentCode
  * @return TokenUiComponentInterface[]
  */
 public function getTokensComponents($vaultPaymentCode)
 {
     $result = [];
     $customerId = $this->session->getCustomerId();
     if (!$customerId) {
         return $result;
     }
     $vaultPayment = $this->getVaultPayment($vaultPaymentCode);
     if ($vaultPayment === null) {
         return $result;
     }
     $vaultProviderCode = $vaultPayment->getProviderCode();
     $componentProvider = $this->getComponentProvider($vaultProviderCode);
     if ($componentProvider === null) {
         return $result;
     }
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::CUSTOMER_ID)->setValue($customerId)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::PAYMENT_METHOD_CODE)->setValue($vaultProviderCode)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::IS_ACTIVE)->setValue(1)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::EXPIRES_AT)->setConditionType('gt')->setValue($this->dateTimeFactory->create('now', new \DateTimeZone('UTC'))->format('Y-m-d 00:00:00'))->create();
     $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
     foreach ($this->paymentTokenRepository->getList($searchCriteria)->getItems() as $token) {
         $result[] = $componentProvider->getComponentForToken($token);
     }
     return $result;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:TokensConfigProvider.php


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


示例20: findCustomerByLoginAttribute

 /**
  * Find a customer
  *
  * @param string $attributeValue Attribute Value
  * @return bool|\Magento\Customer\Api\Data\CustomerInterface
  */
 private function findCustomerByLoginAttribute($attributeValue)
 {
     // Retrieve the customer login attribute and check if valid
     $loginAttribute = $this->advancedLoginConfigProvider->getLoginAttribute();
     if (false === $loginAttribute) {
         return false;
     }
     // Add website filter if customer accounts are shared per website
     $websiteIdFilter = false;
     if ($this->advancedLoginConfigProvider->getCustomerAccountShareScope() == Share::SHARE_WEBSITE) {
         $websiteIdFilter[] = $this->filterBuilder->setField('website_id')->setConditionType('eq')->setValue($this->storeManager->getStore()->getWebsiteId())->create();
     }
     // Add customer attribute filter
     $customerNumberFilter[] = $this->filterBuilder->setField('customer_number')->setConditionType('eq')->setValue($attributeValue)->create();
     // Build search criteria
     $searchCriteriaBuilder = $this->searchCriteriaBuilder->addFilters($customerNumberFilter);
     if ($websiteIdFilter) {
         $searchCriteriaBuilder->addFilters($websiteIdFilter);
     }
     $searchCriteria = $searchCriteriaBuilder->create();
     // Retrieve the customer collection and return customer if there was exactly one customer found
     $collection = $this->customerRepository->getList($searchCriteria);
     if ($collection->getTotalCount() == 1) {
         return $collection->getItems()[0];
     }
     return false;
 }
开发者ID:semaio,项目名称:magento2-advancedlogin,代码行数:33,代码来源:AccountManagement.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Api\SearchCriteriaBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP Api\ExtensibleDataObjectConverter类代码示例发布时间: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