Add extra field to aceshop/opencart component in joomla

Links for php scripts

Moderators: macek, egami, gesf

phpkiller
New php-forum User
New php-forum User
Posts: 31
Joined: Thu Jun 28, 2012 2:11 pm

Add extra field to aceshop/opencart component in joomla

Postby phpkiller » Wed Oct 16, 2013 5:15 am

1. Add this line to getForm() method in admin/controller/catalog/product.php :-

$this->data['entry_external_link'] = $this->language->get('entry_external_link');

2. Add same variable in language file i.e. admin/language/english/catalog/product.php :-

$_['entry_external_link'] = 'External Link';


3. Add this code block just after "$product_id = $this->db->getLastId();" in admin/model/catalog/product.php addProduct() :-

if (isset($data['external_link'])) {
$this->db->query("UPDATE " . DB_PREFIX . "product SET external_link = '" . $this->db->escape(html_entity_decode($data['external_link'], ENT_QUOTES, 'UTF-8')) . "' WHERE product_id = '" . (int)$product_id . "'");
}


4. Same code block to add in editproduct() (approx at line 130):-

5. Now go to admin/view/template/catalog/product_form.tpl and insert this code block in your form (approx at line no. 35) :-

<tr>
<td><?php echo $entry_external_link; ?></td>
<td><input type="text" name="external_link" value="<?php echo $external_link; ?>" size="80" /></td>
</tr>


6. Here done admin part. Now move to front-end :-

7. Now add this line to catalog/controller/product/product.php (approx at line no. 260) :-

$this->data['entry_external_link'] = $this->language->get('entry_external_link');

8. Add this code block at line no. 285 in same file :-

$this->data['external_link'] = $product_info['external_link'];

if ($product_info['quantity'] <= 0) {
$this->data['stock'] = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$this->data['stock'] = $product_info['quantity'];
} else {
$this->data['stock'] = $this->language->get('text_instock');
}


9. Add variable to language file i.e. catalog/language/english/product/product.php

$_['text_external_link'] = 'External Link';

10. Now add value to array in getProduct() in catalog/model/catalog/product.php :-

'external_link' => $query->row['external_link'],

11. Now you can use this to your view page i.e. catalog/view/theme/default/template/product/product.tpl.

12. Before all this code blocks you first add one extra field to your product table as external_link.(provide same field in model funtions)

phpkiller
New php-forum User
New php-forum User
Posts: 31
Joined: Thu Jun 28, 2012 2:11 pm

Re: Add extra field to aceshop/opencart component in joomla

Postby phpkiller » Thu Feb 13, 2014 2:11 am

In firts point after adding variable add this code block to display thae value in database to that same field:

At line 710:

/* Added code for new field */
if (isset($this->request->post['external_link'])) {
$this->data['external_link'] = $this->request->post['external_link'];
} elseif (isset($product_info)) {
$this->data['external_link'] = $product_info['external_link'];
} else {
$this->data['external_link'] = '';
}
/* end */



Done.


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest