Jump to content

Back office custom order / Search customer by phone


prototypo
 Share

Recommended Posts

In back office order of Prestashop 1.6 i want to search customers by mobile phone. By default you can search by name / email and birthday.

I cannot find the file and the search function to customize it.

Anyone knows where it is?

320372203_.thumb.png.7bbab0d1ad3cd25fe76b3866fbfdde9b.png

εικόνα.png

Edited by prototypo (see edit history)

Share this post


Link to post
Share on other sites

The problem with your idea is that phone number is linked to Address and not to Customer

You need to search by Phone->Address->Customer.

But the main problem is that Phone Number is not unique key, so every customer can add, for example Address with phone number 00000 (Example)

 

Share this post


Link to post
Share on other sites

17 minutes ago, Amantha Bill said:

The problem with your idea is that phone number is linked to Address and not to Customer

You need to search by Phone->Address->Customer.

But the main problem is that Phone Number is not unique key, so every customer can add, for example Address with phone number 00000 (Example)

 

Why don't you write a solution?
Of course, it is a small modification of the code !!!

Share this post


Link to post
Share on other sites

On 5/16/2020 at 12:13 AM, prototypo said:

In back office order of Prestashop 1.6 i want to search customers by mobile phone. By default you can search by name / email and birthday.

I cannot find the file and the search function to customize it.

Anyone knows where it is?

 

FTP:

1. open ./classes/Customer.php

2. find function: public static function searchByName

3. replace function to:

public static function searchByName($query, $limit = null)
    {
        $sql = 'SELECT a.*, b.phone, b.phone_mobile
                FROM `' . _DB_PREFIX_ . 'customer` a
                LEFT JOIN '._DB_PREFIX_.'address b ON (a.id_customer = b.id_customer)
                WHERE 1';
        $search_items = explode(' ', $query);
        $research_fields = array('a.id_customer', 'a.firstname', 'a.lastname', 'a.email', 'b.phone', 'b.phone_mobile');
        if (Configuration::get('PS_B2B_ENABLE')) {
            $research_fields[] = 'company';
        }

        $items = array();
        foreach ($research_fields as $field) {
            foreach ($search_items as $item) {
                $items[$item][] = $field . ' LIKE \'%' . pSQL($item) . '%\' ';
            }
        }

        foreach ($items as $likes) {
            $sql .= ' AND (' . implode(' OR ', $likes) . ') ';
        }

        $sql .= Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);

        if ($limit) {
            $sql .= ' LIMIT 0, ' . (int) $limit;
        }

        return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
    }

4. save Customer.php

DONE 😉

 

Or create override Customer.php

Share this post


Link to post
Share on other sites

9 hours ago, Guest said:

By editing the code, you can search, for example, by city, street, etc.

Omg i asked only the file location and you gave me the total solution! Even with the file ready to download!!!!!!
Thank you so much! You are great!

Can you help me please for some more customizations just by giving me some informations and not the total solution again? :D

Share this post


Link to post
Share on other sites

After all, by comparing the function in the original and the modified function, you can see the difference, which perhaps does not need an explanation.
Do you want to add eg a city:
in the SQL query you add b.city and in the array research_fields you also add b.city.

Share this post


Link to post
Share on other sites

If I helped you, you can give my posts like by clicking on the gray heart below my posts.

Share this post


Link to post
Share on other sites

7 hours ago, Guest said:

After all, by comparing the function in the original and the modified function, you can see the difference, which perhaps does not need an explanation.
Do you want to add eg a city:
in the SQL query you add b.city and in the array research_fields you also add b.city.

Yes i understand what you did! I made some customizations bymyself in other functions and i learned how it works. For example, i managed to add fields "search by phone" and "mobile phone" in customers addresses. But in this case with back office order search field i was looking the solution in wrong place in order files and not in customers. I was searching for function with a name something like searchcustomer and the function was searchByName!

Now i search the way to auto add a product reference number same with product ID while you save a new product.

I know how to copy the ID's in product reference field in SQL but i want this to be done automatically every time you save the product. Any idea?

Thanks you very much, you already save me a lot of time!



 

Share this post


Link to post
Share on other sites

How to do it.

Just edit the sample and find the highest id_product number from the database and add +1.

Share this post


Link to post
Share on other sites

33 minutes ago, Guest said:

How to do it.

Just edit the sample and find the highest id_product number from the database and add +1.

Where i can find this function in prestashop 1.6? It's not inside AdminProductsController.php

Edited by prototypo (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More