Filter apply to more categories

  • Posts: 34
  • Thank you received: 1
9 years 8 months ago #193587

-- url of the page with the problem -- : www.erlautek.hu
-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.3.27
-- Browser(s) name and version -- : Chrome 41.0.2272.76 m

Hi,
Please help me, how I could apply a filter to more categories.
In Hikashop v2.3.5 I have set up with the same name a filter per category,
but in v2.4.0 it is not allowed to set up filters with the same name.

Thank you for your help in advance.

Please Log in or Create an account to join the conversation.

  • Posts: 82865
  • Thank you received: 13373
  • MODERATOR
9 years 8 months ago #193679

Hi,

Indeed we had to strengthen the rules.
Change the code:

if(empty($filter->filter_id)) {
			$filter->filter_namekey=$filter->filter_name;
			$search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u");
			$replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u");
			$test = str_replace($search, $replace, $filter->filter_namekey);
			$test = preg_replace('#[^a-z0-9_-]#i','',$test);

			if(empty($test)) {
				$query = 'SELECT MAX(`filter_id`) FROM '.hikashop_table('filter');
				$this->database->setQuery($query);
				$last_pid = (int)$this->database->loadResult() + 1;
				$filter->filter_namekey = 'filter_'.$last_pid;
			} else {
				$query = 'SELECT filter_id FROM '.hikashop_table('filter').' WHERE filter_namekey  = '.$this->database->Quote($filter->filter_name).' AND filter_id!='.(int)$filter->filter_id.' LIMIT 1';
				$this->database->setQuery($query);
				if($this->database->loadResult()) {
					$app = JFactory::getApplication();
					$app->enqueueMessage(JText::_('DUPLICATE_PRODUCT'), 'error');
					JRequest::setVar('fail', $filter);
					return false;
				}
				$test = str_replace($search, $replace, $filter->filter_name);
				$filter->filter_namekey = preg_replace('#[^a-z0-9_-]#i','_',$test);
			}
		}
to:
if(empty($filter->filter_id)) {
			$filter->filter_namekey=$filter->filter_name;
			$search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u");
			$replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u");
			$test = str_replace($search, $replace, $filter->filter_namekey);
			$filter->filter_namekey = preg_replace('#[^a-z0-9_-]#i','',$test);

			if(empty($test)) {
				$filter->filter_namekey = 'filter';
			}
			$query = 'SELECT MAX(`filter_id`) FROM '.hikashop_table('filter');
			$this->database->setQuery($query);
			$last_pid = (int)$this->database->loadResult() + 1;
			$filter->filter_namekey .= '_'.$last_pid;
		}
in the file administrator/components/com_hikashop/classes/filter.php and that should avoid the problem.

The following user(s) said Thank You: plengyel

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 1
9 years 8 months ago #193717

Hi Nicolas,

I have modified the code, and now it's possible
to create filters with the same name.

Thanks for your help.

Please Log in or Create an account to join the conversation.

Time to create page: 0.047 seconds
Powered by Kunena Forum