Post by Joe1234 » Thu Oct 12, 2023 11:01 am

I saw an ocmod that allowed you to limit the amount of products on the admin catalogue page to whatever amount. I went back but can't find it and I don't remember the search string I was using when I saw it. Has anybody come across a mod like this whether it is dedicated or part of a larger mod?
Last edited by Joe1234 on Sat Oct 28, 2023 1:04 am, edited 1 time in total.

v3.0.3.8
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 softmonke » Thu Oct 12, 2023 12:00 pm

OpenCart already has an existing option for you to set how many items to display per page, where the default is 20.

This option can be found under System -> Settings -> 'edit' for your default store -> 'Option' tab -> 'Default Items Per Page (Admin)' option. But do note that this applies to everything across the admin panel, such as customers, orders, etc.

Reach out to us at hello@softmonke.com for your OpenCart web development needs.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by Joe1234 » Fri Oct 13, 2023 1:10 am

Yeah I know about that thanks. But I specifically want this mod/feature.

v3.0.3.8
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 softmonke » Fri Oct 13, 2023 5:47 am

Joe1234 wrote:
Fri Oct 13, 2023 1:10 am
Yeah I know about that thanks. But I specifically want this mod/feature.
Well, if you don't mind hardcoding the number of products to display on the page, just go to "admin/controller/catalog", open up "product.php", and replace all instances of:

Code: Select all

$this->config->get('config_limit_admin')
with whatever number you want to display, i.e. 100.

Reach out to us at hello@softmonke.com for your OpenCart web development needs.


User avatar
Active Member

Posts

Joined
Tue May 23, 2023 4:42 am


Post by Joe1234 » Wed Oct 18, 2023 9:56 am

I actually did that a long time ago and have it set to a decent amount. I was specifically looking for this capability because sometimes I'm in the listview and I'd like to expand to all or half the products to scan and check something quickly. I guess I'll just keep an eye out to come across it again.

v3.0.3.8
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 Joe1234 » Sat Oct 28, 2023 12:53 am

It was annoying the hell out of me that I couldn't find this mod, and once I saw it I really wanted it, so I went ahead and made one for myself. I'm sure there is a more elegant way to do this, so someone feel free to make the code cleaner/more efficient and repost.


Put this somewhere in admin\view\template\catalog\product_list.twig

Code: Select all

<div class="col-sm-1 text-left">

	<select onchange="custom_list_limits(this.value)" class="form-control">
		<option value="*"></option>
			  {% for list_limit in list_limits %}
				  {% if list_limit ==  list_limit_value  %}
				  	<option value="{{ list_limit }}" selected="selected">{{ list_limit }}</option>
				  {% else %}
					<option value="{{ list_limit }}">{{ list_limit }}</option>
				  {% endif %}
			 {% endfor %}
	</select>

</div>

Put this somewhere at the bottom of the same twig file with the rest of the javascript. Change the admin folder name if you changed yours.

Code: Select all

<script>//Set the product list limit within the product list (this will also set the limit for all other lists in the admin). 
		//Come back to this at some point to make it only for the product list

	function custom_list_limits(str) {

		var xmlhttp = new XMLHttpRequest();

		//Send the limit count to the function to update the database
		xmlhttp.open("GET","index.php?route=catalog/product/custom_pass_new_limit&user_token={{ user_token }}&q="+str,true);
		xmlhttp.send();

		//Sleep so the database has time to update
		wait(250);  //.25 seconds in milliseconds

		//Reset the window with the new limit set
		window.location = ('/admin/index.php?route=catalog/product&user_token={{ user_token }}')

	}

	//Sleep
	function wait(ms){
		var start = new Date().getTime();
		var end = start;
		while(end < start + ms) {
			end = new Date().getTime();
		}
	}
</script>

Put this in admin\controller\catalog\product.php in getList() just above '$pagination = new Pagination();'

Code: Select all

		$data['list_limits'] = array();
		$data['list_limits'] = array(
			'25'	=> "25",
			'50' 	=> "50",
			'75'	=> "75",
			'100'	=> "100",
			'150'	=> "150",
			'200' 	=> "200",
			'250'	=> "250",
			'300'	=> "300"
		);

		$data['list_limit_value'] = $this->config->get('config_limit_admin');

Put this in the same controller

Code: Select all

public function custom_pass_new_limit() {

	$q = intval($_GET['q']);

	if (isset($q) && $q > 1) {
		$newlimit = $q;
	} else {
		$newlimit = $this->config->get('config_limit_admin');
	}

	$this->load->model('catalog/product');

	$this->model_catalog_product->custom_set_new_limit($newlimit);

//$this->getList();
}

Put this in admin\model\catalog\product.php.

Code: Select all

public function custom_set_new_limit($str_limit) {

	$this->db->query("UPDATE " . DB_PREFIX . "setting SET VALUE = '" . (int)$str_limit . "' WHERE `key` = 'config_limit_admin'");

}

v3.0.3.8
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
Who is online

Users browsing this forum: JNeuhoff, Mike Guenther, paulfeakins, Semrush [Bot] and 25 guests