rusty Posted May 7, 2010 Share Posted May 7, 2010 How do I comment out periods in categories that need them?For example I have a auto repair shop that has products for 2.0L Vehicles and I need the category to say 2.0L Link to comment Share on other sites More sharing options...
rocky Posted May 8, 2010 Share Posted May 8, 2010 Unfortunately, I can't figure out how to do this without modifying code. I suggest that you modify the hideCategoryPosition function in classes/Category.php: static public function hideCategoryPosition($name) { return preg_replace('/^[0-9]+\./', '', $name); } If you don't want to use the category prefix at all, you could change it to: static public function hideCategoryPosition($name) { return /*preg_replace('/^[0-9]+\./', '', */$name/*)*/; } If you want to use the category prefix, but there are some exceptions, I suggest putting those exceptions in the function like this: static public function hideCategoryPosition($name) { if ($name == '2.0L Vehicles') return $name; return preg_replace('/^[0-9]+\./', '', $name); } You may also need to change lines 104-122 of classes/Category.php from: public function add($autodate = true, $nullValues = false) { $this->level_depth = $this->calcLevelDepth(); foreach ($this->name AS $k => $value) if (preg_match('/^[1-9]\./', $value)) $this->name[$k] = '0'.$value; $ret = parent::add($autodate); $this->updateGroup(Tools::getValue('groupBox')); return $ret; } public function update($nullValues = false) { $this->level_depth = $this->calcLevelDepth(); foreach ($this->name AS $k => $value) if (preg_match('/^[1-9]\./', $value)) $this->name[$k] = '0'.$value; return parent::update(); } to: public function add($autodate = true, $nullValues = false) { $this->level_depth = $this->calcLevelDepth(); /* foreach ($this->name AS $k => $value) if (preg_match('/^[1-9]\./', $value)) $this->name[$k] = '0'.$value; */ $ret = parent::add($autodate); $this->updateGroup(Tools::getValue('groupBox')); return $ret; } public function update($nullValues = false) { $this->level_depth = $this->calcLevelDepth(); /* foreach ($this->name AS $k => $value) if (preg_match('/^[1-9]\./', $value)) $this->name[$k] = '0'.$value; */ return parent::update(); } to prevent "2.0 Vehicles" being automatically changed to "02.0 Vehicles". Link to comment Share on other sites More sharing options...
rusty Posted May 8, 2010 Author Share Posted May 8, 2010 This worked great Thank you. I decided, since my import was more dynamic, to use the php strpos() function static public function hideCategoryPosition($name) { if (strpos($name,'2.0') || strpos($name,'1.8') || strpos($name,'2.8') || strpos($name,'3.0') || strpos($name,'05.5') || strpos($name,'03.5') || strpos($name,'99.5') || strpos($name,'4.2') || strpos($name,'3.2') || strpos($name,'2.5') || strpos($name,'3.6')) return $name; return preg_replace('/^[0-9]+\./', '', $name); } Thanks a bunch. Link to comment Share on other sites More sharing options...
rocky Posted May 8, 2010 Share Posted May 8, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
Recommended Posts