Post by Marco75 » Mon Nov 01, 2010 10:28 pm

Hello,

I really have many products in my shop and I will like to know how to put a warning when creating a product, if the model already exists in my DB.

Example

I create a product and seized an existing model in my database.
If I did not alert, I can create several times the same product, which is detrimental.

Thank you for your suggestions.
Last edited by Marco75 on Wed Nov 03, 2010 6:33 pm, edited 1 time in total.

My version > 1.4.9.3


Newbie

Posts

Joined
Thu Oct 28, 2010 6:48 pm

Post by Qphoria » Wed Nov 03, 2010 12:03 pm

1. EDIT: admin/controller/catalog/product.php

2. FIND (AT THE VERY BOTTOM):

Code: Select all

}
?>
3. BEFORE, ADD:

Code: Select all

public function modelCheck() {
        $this->load->model('catalog/product');

        $output = '';

        $result = $this->getTotalProductsByField('model', $this->request->get['model']);

        $output .= '<span id="modelcheck">';

        if ($result) {
            $output .= 'Model Number Already Exists!';
        }

         $output .= '</span>';

        $this->response->setOutput($output, $this->config->get('config_compression'));
    }

    private function getTotalProductsByField($field, $value) {
        $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE `" . $field . "` = '" . $value . "'");

        return $query->row['total'];
    } 
4. EDIT: admin/view/template/catalog/product_form.tpl

5. FIND:

Code: Select all

<input type="text" name="model" value="<?php echo $model; ?>" />
6. REPLACE WITH:

Code: Select all

<input type="text" name="model" value="<?php echo $model; ?>" onchange="$('#modelcheck').remove(); $('#modelwarn').remove(); $(this).after($('<span>').attr('id', 'modelwarn').css('margin-left', '10px').addClass('required').load('index.php?route=catalog/product/modelCheck&token=<?php echo $token; ?>&model=' + escape(this.value)));" />

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Marco75 » Wed Nov 03, 2010 6:31 pm

it's great.

Many thanks

My version > 1.4.9.3


Newbie

Posts

Joined
Thu Oct 28, 2010 6:48 pm

Post by Marco75 » Wed Nov 03, 2010 6:55 pm

Is it possible to change the language of the warning?

My version > 1.4.9.3


Newbie

Posts

Joined
Thu Oct 28, 2010 6:48 pm

Post by Marco75 » Thu Nov 04, 2010 8:29 pm

added it in admin/controller/catalog/product.php

Code: Select all

		$this->data['text_modelcheck'] = $this->language->get('text_modelcheck');
Then put the translation files in admin/languages/LANGUAGE/catalog/product.php

Then I changed

Code: Select all

            if ($result) {
                $output .= 'Model Number Already Exists!';
            }
By

Code: Select all

            if ($result) {
                $output .= $this->language->get('text_modelcheck');
            }
But it shows
text_modelcheck

My version > 1.4.9.3


Newbie

Posts

Joined
Thu Oct 28, 2010 6:48 pm

Post by vista66 » Sun Oct 30, 2011 10:56 pm

hi.
i am using oc 1.4.9.6

i used location for product code fields

now i want if product location is repeated alert me is repeat

for example

my product1 have location 255541 and saved

i want to when i insert product2 and use location 255541 , alert me is repeated and try again


thanks

New member

Posts

Joined
Sun Aug 21, 2011 3:37 pm

Post by vista66 » Mon Oct 31, 2011 4:38 pm

any idea ???

New member

Posts

Joined
Sun Aug 21, 2011 3:37 pm

Post by vista66 » Wed Nov 02, 2011 8:05 pm

i replace model variable with location but is not work ???

New member

Posts

Joined
Sun Aug 21, 2011 3:37 pm

Post by yiyinlah » Sat Feb 25, 2012 12:07 am

Is this working for 1.5.1.3?

I'm using Opencart 1.5.4.1 & vQmod 2.3.2.


User avatar
Active Member

Posts

Joined
Thu Sep 23, 2010 1:19 pm
Location - Singapore

Post by celestial » Sat Feb 25, 2012 1:43 am

yiyinlah wrote:Is this working for 1.5.1.3?
YES

Celestial - Martín Abel Rosales
WhatsApp: 50671482211
Email: martinrosales2012@hotmail.com
Skype: martin.abel.rosales
San José , Costa Rica


User avatar
Expert Member

Posts

Joined
Sat Mar 20, 2010 4:19 am
Location - Costa Rica

Post by yiyinlah » Sat Feb 25, 2012 3:19 am

Thanks babe! :)

I'm using Opencart 1.5.4.1 & vQmod 2.3.2.


User avatar
Active Member

Posts

Joined
Thu Sep 23, 2010 1:19 pm
Location - Singapore
Who is online

Users browsing this forum: No registered users and 2 guests