Post by JakeHerp » Tue Mar 08, 2016 10:46 pm

Hi there,

I am working on a wholesale shop with OpenCart. The problem I am facing is, that my clients know their customers by the company names, but not by the contact person registered to their website. Therefore we need to show the company names instead of the persons names in the admin panel.
Is there any way of achieving this, without hard coding any changes in the admin templates?

Many thanks,
Jacob

Newbie

Posts

Joined
Thu Jan 08, 2015 11:44 pm

Post by daniGo » Tue Mar 08, 2016 10:59 pm

The problem is that company name is located in address table not customer. You can try add this in customer controller:

Code: Select all

$address_info = $this->model_customer_customer->getAddress($result['address_id']);
			
if ($address_info && $address_info['company']) {
	$name = $address_info['company'];
} else {
	$name = $result['name'];
}

$data['customers'][] = array(
	'customer_id'    => $result['customer_id'],
	'name'              => $name,

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia


Post by madimar » Tue Mar 08, 2016 11:03 pm

you can search in extension store, i developed an extention to do so..


Inviato dal mio Find 5 utilizzando Tapatalk

-----------------------------------------------------------------------
My last mods: Partita IVA e CF | Pro EU VAT Number | Sales Agents | Pricelist Pro
-----------------------------------------------------------------------


User avatar
Active Member

Posts

Joined
Thu Sep 24, 2009 6:27 pm


Post by JakeHerp » Tue Mar 08, 2016 11:23 pm

daniGo wrote:The problem is that company name is located in address table not customer. You can try add this in customer controller:

Code: Select all

$address_info = $this->model_customer_customer->getAddress($result['address_id']);
			
if ($address_info && $address_info['company']) {
	$name = $address_info['company'];
} else {
	$name = $result['name'];
}

$data['customers'][] = array(
	'customer_id'    => $result['customer_id'],
	'name'              => $name,
Thanks for that, but the code returns the following error:
Fatal error: Call to a member function getAddress() on null in /home/../public_html/admin/controller/sale/customer.php on line 478

Newbie

Posts

Joined
Thu Jan 08, 2015 11:44 pm

Post by daniGo » Tue Mar 08, 2016 11:27 pm

Which OC version you use?

Try change

$this->model_customer_customer->getAddress($result['address_id']);

in
$this->model_sale_customer->getAddress($result['address_id']);

http://www.gombac.si


Active Member

Posts

Joined
Wed Mar 20, 2013 4:49 pm
Location - Slovenia

Post by JakeHerp » Wed Mar 09, 2016 12:34 am

Now I get
Notice: Undefined variable: address_info in /home/../public_html/admin/controller/sale/customer.php on line 480
Version is 2.0.3.1

Newbie

Posts

Joined
Thu Jan 08, 2015 11:44 pm

Post by ocart777 » Wed Mar 09, 2016 1:01 am

if you just want to display company name instead of customer first/last name on Admin->Customers->Customers(LIST)
then just modify the model file "admin/model/customer/customer.php"(use vqmod better)
search for:

Code: Select all

public function getCustomers($data = array()) {
$sql = "I CAN'T PASTE DOWN THE DEFAULT CODE AS OF OPENCART WEBSITE WONT ALLOW ME TO DO IT, SEARCH ABOVE LINE INSTEAD";
replace with:

Code: Select all

public function getCustomers($data = array()) {
$sql = "SELECT c.*, ad.company AS name, cgd.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (c.customer_group_id = cgd.customer_group_id) LEFT JOIN " . DB_PREFIX . "address ad ON (ad.address_id = c.address_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";

You can't control the weather, but you can change your mood.
You can't modify the visage, but you can show your smile.
You can't command someone else, but you can hold yourself.
You can't forecast tomorrow, but you can using today.
You can't obtain thanks, but you can exert yourself in everything.


OCEXTENSION.COM - YOUR PROFESSIONAL OPENCART EXTENSION STORE


User avatar
Active Member

Posts

Joined
Mon Jun 10, 2013 4:57 pm
Location - Malaysia

Post by JakeHerp » Wed Mar 09, 2016 3:36 am

Thanks, that actually worked. However the search does not seem to work anymore. When I click on the "Customer" input field it shows me the 5 first customers, but when I start typing no further predictions come up and even if I select one of the automatic predictions, it returns no results. Any idea what's wrong here?

Newbie

Posts

Joined
Thu Jan 08, 2015 11:44 pm

Post by kirkhall » Wed Mar 09, 2016 6:23 am

We also needed to be able to see in a column the company name from sales list or company list and to be able to filter customers and orders by company name.
This extension works and we just happen to be using it on the same version of OC as you are.
https://www.opencart.com/index.php?rout ... _id=670060.
It is just a one file vqmod install and you can move on.

Active Member

Posts

Joined
Thu May 22, 2014 11:31 am

Post by ocart777 » Wed Mar 09, 2016 1:10 pm

search for "C O N C A T(c.firstname, ' ', c.lastname) LIKE" and replace it with "ad.company LIKE"
please note that there are no spaces on "C O N C A T" on the real code

You can't control the weather, but you can change your mood.
You can't modify the visage, but you can show your smile.
You can't command someone else, but you can hold yourself.
You can't forecast tomorrow, but you can using today.
You can't obtain thanks, but you can exert yourself in everything.


OCEXTENSION.COM - YOUR PROFESSIONAL OPENCART EXTENSION STORE


User avatar
Active Member

Posts

Joined
Mon Jun 10, 2013 4:57 pm
Location - Malaysia
Who is online

Users browsing this forum: No registered users and 425 guests