Post by Joe1234 » Tue May 17, 2022 12:17 am

I have a couple questions on this, but first, how do I edit the amount of displayed items on the input dropdown? The categories input in the product edit page for example. What controls the amount of items dropdown? I assume it's a central place or a default amount because everything even extensions have the same amount of items showing, but I don't see where to input the count anywhere.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by by mona » Tue May 17, 2022 1:02 am


DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Joe1234 » Tue May 17, 2022 11:06 am

Thanks for that. It isn't directly helping me with what I'm trying to adjust now, but it did fix the annoying inputs I couldn't bother getting to. But back to the one I actually wanted it for, of course it isn't working for that one. So I tried to hack around to get it to work, but it still isn't going my way.
This is what I started with:

Code: Select all

	public function autocomplete()
	{
		$json = array();

		$this->load->model($this->folder.'/'.$this->extension);

		$results = $this->{'model_'.$this->folder.'_'.$this->extension}->getProducts($this->request->get['keyword']);

		$this->load->model('tool/image');

		foreach ($results as $result) {
			$json[] = array(
				'id' => $result['product_id'],
				'status' => $result['status'],
				'image' => $this->model_tool_image->resize(($result['image'] ? $result['image'] : 'no_image.png'), 80, 80),
				'name' => strip_tags(html_entity_decode($result['name'].' - '.$result['sku'], ENT_QUOTES, 'UTF-8')));
		}

		$sort_order = array();

		foreach ($json as $key => $value) {
			$sort_order[$key] = $value['name'];
		}

		array_multisort($sort_order, SORT_ASC, $json);

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
This is what I tried, but it wont work:

Code: Select all

	public function autocomplete()
	{
		$json = array();
		if (isset($this->request->get['keyword'])) {
		$this->load->model($this->folder.'/'.$this->extension);

		$filter_data = array(
		'keyword' => $this->request->get['keyword'],
		'start' => 0,
		'limit' => 10);

		$results = $this->{'model_'.$this->folder.'_'.$this->extension}->getProducts($filter_data);

		$this->load->model('tool/image');

		foreach ($results as $result) {
			$json[] = array(
				'id' => $result['product_id'],
				'status' => $result['status'],
				'image' => $this->model_tool_image->resize(($result['image'] ? $result['image'] : 'no_image.png'), 80, 80),
				'name' => strip_tags(html_entity_decode($result['name'].' - '.$result['sku'], ENT_QUOTES, 'UTF-8')));
		}
}
		$sort_order = array();

		foreach ($json as $key => $value) {
			$sort_order[$key] = $value['name'];
		}

		array_multisort($sort_order, SORT_ASC, $json);

		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
Also, on a side note, I can't get the auto complete to search "properly" due to slight modification I made to the name.
This:

Code: Select all

'name' => strip_tags(html_entity_decode($result['name'].' - '.$result['sku'], ENT_QUOTES, 'UTF-8')));
Was originally this:

Code: Select all

'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')));
I can get it to auto search properly when I'm putting in the original names with my modification, but if I am entering the sku, things wont auto populate. How can I tackle this?

Thanks.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by by mona » Tue May 17, 2022 1:03 pm

It works exactly the same.
Must be your modification / your hack workaround.

It is a simple task - change the 5 to whatever number you want and add a scroll with css.
Search the marketplace - I am pretty sure OSWorX made a free mod for it.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Joe1234 » Tue May 17, 2022 6:01 pm

I tried osworx's and his didn't work for me for whatever reason on ANY of my inputs it didn't create the setting input, so I used
https://www.opencart.com/index.php?rout ... _license=0
instead which did create the settings input and worked on all the inputs except this extension that I need it for. It didn't work on this extension because this extension didn't have the limit on it in the controller in the first place to act on. So I put the limit in but still not the result I was looking for. Either way, I found the reason. This developer put the limit in the model query so I changed it there and all is good now.

Do you happen to see the problem with my second issue?

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by straightlight » Tue May 17, 2022 6:34 pm

Joe1234 wrote:
Tue May 17, 2022 6:01 pm
I tried osworx's and his didn't work for me for whatever reason on ANY of my inputs it didn't create the setting input, so I used
https://www.opencart.com/index.php?rout ... _license=0
instead which did create the settings input and worked on all the inputs except this extension that I need it for. It didn't work on this extension because this extension didn't have the limit on it in the controller in the first place to act on. So I put the limit in but still not the result I was looking for. Either way, I found the reason. This developer put the limit in the model query so I changed it there and all is good now.

Do you happen to see the problem with my second issue?
Since you found an extension that could solve your issue, please add: [SOLVED] at the beginning of the subject line on your first post. However, an alternative could of been used by adding an event trigger in this case.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 273 guests