Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SubTotals.php
Go to the documentation of this file.
1 <?php
7 
13 {
21  protected function _countSum($index, $collection)
22  {
23  $sum = 0;
24  foreach ($collection as $item) {
25  $sum += $item[$index];
26  }
27  return $sum;
28  }
29 
37  protected function _countAverage($index, $collection)
38  {
39  $itemsCount = count($collection);
40  return $itemsCount ? $this->_countSum($index, $collection) / $itemsCount : $itemsCount;
41  }
42 }
$index
Definition: list.phtml:44