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


PHP SearchCriteriaBuilder::setPageSize方法代码示例

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


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

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

示例2: getSearchCriteria

 /**
  * Creates a search criteria DTO based on the array of field filters.
  *
  * @return SearchCriteria
  */
 protected function getSearchCriteria()
 {
     foreach ($this->fieldFilters as $filter) {
         // array of fields, put filters in array to use 'or' group
         /** @var Filter[] $filterGroup */
         $filterGroup = [];
         if (!is_array($filter['field'])) {
             // just one field
             $filterGroup = [$this->createFilterData($filter['field'], $filter['condition'])];
         } else {
             foreach ($filter['field'] as $index => $field) {
                 $filterGroup[] = $this->createFilterData($field, $filter['condition'][$index]);
             }
         }
         $this->searchCriteriaBuilder->addFilter($filterGroup);
     }
     foreach ($this->_orders as $field => $direction) {
         /** @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);
     }
     $this->searchCriteriaBuilder->setCurrentPage($this->_curPage);
     $this->searchCriteriaBuilder->setPageSize($this->_pageSize);
     return $this->searchCriteriaBuilder->create();
 }
开发者ID:opexsw,项目名称:magento2,代码行数:32,代码来源:AbstractServiceCollection.php

示例3: getList

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


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