I am attempting to change the URL in the layered navigation so it doesn’t use ID numbers (but instead use the text value of the attribute being filtered)
On one end of this spectrum is this code in app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php function apply()
protected function _getOptionText($optionId) { return $this->getAttributeModel()->getFrontend()->getOption($optionId); }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { $filter = $request->getParam($this->_requestVar); //$fitler = the number (id, for instance '6') of the attribute $text = $this->_getOptionText($filter); //$text = outputs the text value (color , for instance 'white') if ($filter && $text) { /*$entityIds = Mage::getSingleton('catalogindex/attribute')->getFilteredEntities($this->getAttributeModel(), $filter, $this->_getFilterEntityIds()); if ($entityIds) { $this->getLayer()->getProductCollection() ->addFieldToFilter('entity_id', array('in' => $entityIds));
I was hoping someone has some idea of how I would be able to take an attribute name/value (’color’ and ‘white’ for instance) and get an ID from it? (Some method I don’t know about or haven’t thought about?)