public function getItemsAsArray() { $items = array(); foreach (parent::getItems() as $itemObject) { $item = array(); $item['id'] = $itemObject->getOptionId(); $item['url'] = $this->htmlEscape($itemObject->getUrl()); if ($this->getSingleChoice()) { /** sinse @version 1.3.0 */ $query = array($this->getRequestValue() => $itemObject->getIsSelected() ? null : $itemObject->getOptionId(), Mage::getBlockSingleton('page/html_pager')->getPageVarName() => null); $item['url'] = Mage::helper('amshopby/url')->getFullUrl($query); } $item['label'] = $itemObject->getLabel(); $item['descr'] = $itemObject->getDescr(); $item['count'] = ''; $item['countValue'] = $itemObject->getCount(); if (!$this->getHideCounts()) { $item['count'] = ' (' . $itemObject->getCount() . ')'; } $item['image'] = ''; if ($itemObject->getImage()) { $item['image'] = Mage::getBaseUrl('media') . 'amshopby/' . $itemObject->getImage(); } if ($itemObject->getImageHover()) { $item['image_hover'] = Mage::getBaseUrl('media') . 'amshopby/' . $itemObject->getImageHover(); } $item['css'] = 'amshopby-attr'; if (in_array($this->getDisplayType(), array(1, 3))) { //dropdown and images $item['css'] = ''; } if ($itemObject->getIsSelected()) { $item['css'] .= '-selected'; if (3 == $this->getDisplayType()) { //dropdown $item['css'] = 'selected'; } } $item['rel'] = $this->getSeoRel() ? ' rel="nofollow" ' : ''; $items[] = $item; } $sortBy = $this->getSortBy(); $functions = array(1 => '_sortByName', 2 => '_sortByCounts'); if (isset($functions[$sortBy])) { usort($items, array($this, $functions[$sortBy])); } // add less/more $max = $this->getMaxOptions(); $i = 0; foreach ($items as $k => $item) { $style = ''; if ($max && ++$i > $max) { $style = 'style="display:none" class="amshopby-attr-' . $this->getRequestValue() . '"'; } $items[$k]['style'] = $style; } $this->setShowLessMore($max && $i > $max); return $items; }
public function getItemsAsArray() { $items = array(); foreach (parent::getItems() as $itemObject) { $item = array(); $item['id'] = $itemObject->getOptionId(); $item['url'] = $this->htmlEscape($itemObject->getUrl()); $item['label'] = $itemObject->getLabel(); $item['descr'] = $itemObject->getDescr(); $item['count'] = ''; $item['countValue'] = $itemObject->getCount(); if (!$this->getHideCounts()) { $item['count'] = ' <span class="count">(' . $itemObject->getCount() . ')</span>'; } $item['image'] = ''; if ($itemObject->getImage()) { $item['image'] = Mage::getBaseUrl('media') . 'amshopby/' . $itemObject->getImage(); } if ($itemObject->getImageHover()) { $item['image_hover'] = Mage::getBaseUrl('media') . 'amshopby/' . $itemObject->getImageHover(); } $item['css'] = 'amshopby-attr'; if (in_array($this->getDisplayType(), array(1, 3))) { //dropdown and images $item['css'] = ''; } if ($itemObject->getIsSelected()) { $item['css'] .= '-selected'; if (3 == $this->getDisplayType()) { //dropdown $item['css'] = 'selected'; } } if ($itemObject->getCount() === 0) { $item['css'] .= ' amshopby-attr-inactive'; } $item['rel'] = $this->getSeoRel() ? ' rel="nofollow" ' : ''; $items[] = $item; } $sortBy = $this->getSortBy(); $functions = array(1 => '_sortByName', 2 => '_sortByCounts'); if (isset($functions[$sortBy])) { usort($items, array($this, $functions[$sortBy])); } // add less/more $max = $this->getMaxOptions(); $i = 0; foreach ($items as $k => $item) { $style = ''; if ($max && ++$i > $max) { $style = 'style="display:none" class="amshopby-attr-' . $this->getRequestValue() . '"'; } $items[$k]['style'] = $style; } $this->setShowLessMore($max && $i > $max); return $items; }