Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
TaxRateCollection Class Reference
Inheritance diagram for TaxRateCollection:
AbstractServiceCollection Collection ArrayInterface CollectionDataSourceInterface OptionSourceInterface ArgumentInterface

Public Member Functions

 __construct (EntityFactory $entityFactory, FilterBuilder $filterBuilder, SearchCriteriaBuilder $searchCriteriaBuilder, SortOrderBuilder $sortOrderBuilder, TaxRateRepositoryInterface $rateService, \Magento\Tax\Model\Calculation\Rate\Converter $rateConverter)
 
 loadData ($printQuery=false, $logQuery=false)
 
- Public Member Functions inherited from AbstractServiceCollection
 __construct (EntityFactoryInterface $entityFactory, FilterBuilder $filterBuilder, SearchCriteriaBuilder $searchCriteriaBuilder, SortOrderBuilder $sortOrderBuilder)
 
 addFieldToFilter ($field, $condition)
 
- Public Member Functions inherited from Collection
 __construct (EntityFactoryInterface $entityFactory)
 
 addFilter ($field, $value, $type='and')
 
 addFieldToFilter ($field, $condition)
 
 getFilter ($field)
 
 isLoaded ()
 
 getCurPage ($displacement=0)
 
 getLastPageNumber ()
 
 getPageSize ()
 
 getSize ()
 
 getFirstItem ()
 
 getLastItem ()
 
 getItems ()
 
 getColumnValues ($colName)
 
 getItemsByColumnValue ($column, $value)
 
 getItemByColumnValue ($column, $value)
 
 addItem (\Magento\Framework\DataObject $item)
 
 getAllIds ()
 
 removeItemByKey ($key)
 
 removeAllItems ()
 
 clear ()
 
 walk ($callback, array $args=[])
 
 each ($objMethod, $args=[])
 
 setDataToAll ($key, $value=null)
 
 setCurPage ($page)
 
 setPageSize ($size)
 
 setOrder ($field, $direction=self::SORT_ORDER_DESC)
 
 setItemObjectClass ($className)
 
 getNewEmptyItem ()
 
 distinct ($flag)
 
 loadData ($printQuery=false, $logQuery=false)
 
 load ($printQuery=false, $logQuery=false)
 
 loadWithFilter ($printQuery=false, $logQuery=false)
 
 toXml ()
 
 toArray ($arrRequiredFields=[])
 
 toOptionArray ()
 
 toOptionHash ()
 
 getItemById ($idValue)
 
 getIterator ()
 
 count ()
 
 getFlag ($flag)
 
 setFlag ($flag, $value=null)
 
 hasFlag ($flag)
 
 __sleep ()
 
 __wakeup ()
 

Protected Member Functions

 createTaxRateCollectionItem (TaxRate $taxRate)
 
- Protected Member Functions inherited from AbstractServiceCollection
 createFilterData ($field, $condition)
 
- Protected Member Functions inherited from Collection
 _setIsLoaded ($flag=true)
 
 _addItem ($item)
 
 _getItemId (\Magento\Framework\DataObject $item)
 
 _renderFilters ()
 
 _renderOrders ()
 
 _renderLimit ()
 
 _toOptionArray ($valueField='id', $labelField='name', $additional=[])
 
 _toOptionHash ($valueField='id', $labelField='name')
 

Protected Attributes

 $taxRateRepository
 
 $rateConverter
 
- Protected Attributes inherited from AbstractServiceCollection
 $fieldFilters = []
 
 $filterBuilder
 
 $searchCriteriaBuilder
 
 $sortOrderBuilder
 
- Protected Attributes inherited from Collection
 $_items = []
 
 $_itemObjectClass = \Magento\Framework\DataObject::class
 
 $_orders = []
 
 $_filters = []
 
 $_isFiltersRendered = false
 
 $_curPage = 1
 
 $_pageSize = false
 
 $_totalRecords
 
 $_isCollectionLoaded
 
 $_flags = []
 
 $_entityFactory
 

Additional Inherited Members

- Data Fields inherited from Collection
const SORT_ORDER_ASC = 'ASC'
 
const SORT_ORDER_DESC = 'DESC'
 

Detailed Description

Tax rate collection for a grid backed by Services

Definition at line 21 of file TaxRateCollection.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( EntityFactory  $entityFactory,
FilterBuilder  $filterBuilder,
SearchCriteriaBuilder  $searchCriteriaBuilder,
SortOrderBuilder  $sortOrderBuilder,
TaxRateRepositoryInterface  $rateService,
\Magento\Tax\Model\Calculation\Rate\Converter  $rateConverter 
)

Initialize dependencies.

Parameters
EntityFactory$entityFactory
FilterBuilder$filterBuilder
SearchCriteriaBuilder$searchCriteriaBuilder
SortOrderBuilder$sortOrderBuilder
TaxRateRepositoryInterface$rateService
\Magento\Tax\Model\Calculation\Rate\Converter$rateConverter

Definition at line 43 of file TaxRateCollection.php.

Member Function Documentation

◆ createTaxRateCollectionItem()

createTaxRateCollectionItem ( TaxRate  $taxRate)
protected

Creates a collection item that represents a tax rate for the tax rates grid.

Parameters
TaxRate$taxRateInput data for creating the item.
Returns
\Magento\Framework\DataObject Collection item that represents a tax rate

Definition at line 79 of file TaxRateCollection.php.

80  {
81  $collectionItem = new \Magento\Framework\DataObject();
82  $collectionItem->setTaxCalculationRateId($taxRate->getId());
83  $collectionItem->setCode($taxRate->getCode());
84  $collectionItem->setTaxCountryId($taxRate->getTaxCountryId());
85  $collectionItem->setTaxRegionId($taxRate->getTaxRegionId());
86  $collectionItem->setRegionName($taxRate->getRegionName());
87  $collectionItem->setTaxPostcode($taxRate->getTaxPostcode());
88  $collectionItem->setRate($taxRate->getRate());
89  $collectionItem->setTitles($this->rateConverter->createTitleArrayFromServiceObject($taxRate));
90 
91  if ($taxRate->getZipTo() != null && $taxRate->getZipFrom() != null) {
92  /* must be a "1" for existing code (e.g. JavaScript) to work */
93  $collectionItem->setZipIsRange("1");
94  $collectionItem->setZipFrom($taxRate->getZipFrom());
95  $collectionItem->setZipTo($taxRate->getZipTo());
96  } else {
97  $collectionItem->setZipIsRange(null);
98  $collectionItem->setZipFrom(null);
99  $collectionItem->setZipTo(null);
100  }
101 
102  return $collectionItem;
103  }
$taxRate
Definition: tax_rule.php:12

◆ loadData()

loadData (   $printQuery = false,
  $logQuery = false 
)

{}

Definition at line 59 of file TaxRateCollection.php.

60  {
61  if (!$this->isLoaded()) {
62  $searchCriteria = $this->getSearchCriteria();
63  $searchResults = $this->taxRateRepository->getList($searchCriteria);
64  $this->_totalRecords = $searchResults->getTotalCount();
65  foreach ($searchResults->getItems() as $taxRate) {
67  }
68  $this->_setIsLoaded();
69  }
70  return $this;
71  }
$searchCriteria
$taxRate
Definition: tax_rule.php:12

Field Documentation

◆ $rateConverter

$rateConverter
protected

Definition at line 31 of file TaxRateCollection.php.

◆ $taxRateRepository

$taxRateRepository
protected

Definition at line 26 of file TaxRateCollection.php.


The documentation for this class was generated from the following file: