Wouldn't it be better to only add the field to the begin of the query, ignoring what comes after, so i can copy & paste the script as often as I want to?
I have a doubt about the way you did it, now that I checked your xml I remember why I didn't use
Code: Select all
<search position="replace"><![CDATA[$this->db->query("UPDATE " . DB_PREFIX . "customer SET ]]></search>
in the search line as you did. The thing is that
"update". DB_PREFIX."customer SET actually appears more than 5 times in the code; therefore, if you tell script to add your field after that line, the vqmod will add it several times in different parts of the code. Not sure if that could cause a problem.
I went to the vqcahe folder to see the changes being made by the xml and I could see our code in the <add trim="true"><![CDATA[our code ]]></add> was added in some parts it is not supposed to be. Take a look below.
vqcache_catalog_model_account_customer.php
Code: Select all
<?php
class ModelAccountCustomer extends Model {
public function addCustomer($data) {
$data['cedu'] = ucwords(strtolower(trim($data['cedu'])));
$data['firstname'] = ucwords(strtolower(trim($data['firstname'])));
$data['lastname'] = ucwords(strtolower(trim($data['lastname'])));
$data['company'] = ucwords(strtolower(trim($data['company'])));
$data['address_1'] = ucwords(strtolower(trim($data['address_1'])));
$data['address_2'] = ucwords(strtolower(trim($data['address_2'])));
$data['city'] = ucwords(strtolower(trim($data['city'])));
$data['postcode'] = strtoupper(trim($data['postcode']));
$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET store_id = '" . (int)$this->config->get('config_store_id') . "', cedu = '" . $this->db->escape($data['cedu']) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', password = '" . $this->db->escape(md5($data['password'])) . "', newsletter = '" . (int)$data['newsletter'] . "', customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "', status = '1', date_added = NOW()");
$customer_id = $this->db->getLastId();
$this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int)$customer_id . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', city = '" . $this->db->escape($data['city']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', country_id = '" . (int)$data['country_id'] . "', zone_id = '" . (int)$data['zone_id'] . "'");
$address_id = $this->db->getLastId();
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cedu = '" . $this->db->escape($data['cedu']) . "', address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$customer_id . "'");
if (!$this->config->get('config_customer_approval')) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cedu = '" . $this->db->escape($data['cedu']) . "', approved = '1' WHERE customer_id = '" . (int)$customer_id . "'");
}
}
public function editCustomer($data) {
$data['cedu'] = ucwords(strtolower(trim($data['cedu'])));
$data['firstname'] = ucwords(strtolower(trim($data['firstname'])));
$data['lastname'] = ucwords(strtolower(trim($data['lastname'])));
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cedu = '" . $this->db->escape($data['cedu']) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
public function editPassword($email, $password) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cedu = '" . $this->db->escape($data['cedu']) . "', password = '" . $this->db->escape(md5($password)) . "' WHERE email = '" . $this->db->escape($email) . "'");
}
public function editNewsletter($newsletter) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cedu = '" . $this->db->escape($data['cedu']) . "', newsletter = '" . (int)$newsletter . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}
public function getCustomer($customer_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
return $query->row;
}
public function getTotalCustomersByEmail($email) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "'");
return $query->row['total'];
}
you can see my field"cedu" after the following lines, and I think it's not suppose to be there.
$address_id = $this->db->getLastId();
if (!$this->config->get('config_customer_approval'))
public function editPassword($email, $password) {
public function editNewsletter($newsletter) {