Post by abmcr » Wed Aug 05, 2009 4:39 pm

Small contribution for add a description on manufacturer: this code is valid for 1.3.

1) create the table

Code: Select all

CREATE TABLE `manufacter_description` (
  `manufacturer_id` int(11) NOT NULL,
  `language_id` int(11) NOT NULL,
  `meta_description` varchar(66) collate utf8_unicode_ci NOT NULL,
  `description` text collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`manufacturer_id`,`language_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
2) in the catalog insert in controller/product/manufacturer.php (line 31)

Code: Select all

$this->document->description = $manufacturer_info['meta_description'];
$this->data['description'] = html_entity_decode($manufacturer_info['description']);

3) in the catalog edit the model/catalog/manufacturer.php and change the function getManufacturer  in 
[code]
	public function getManufacturer($manufacturer_id) {
		
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "manufacturer m LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (m.manufacturer_id = md.manufacturer_id) WHERE m.manufacturer_id = '" . (int)$manufacturer_id . "' AND md.language_id = '" . (int)$this->language->getId() . "'");
	
		return $query->row;	
	}
[/code]

4) in the template of catalog (view/theme/template/product/manufacturer.tpl) add at line 4

Code: Select all

<?php if ($description) { ?>
  <div style="margin-bottom: 15px;"><?php echo $description; ?></div>
  <?php } ?>
Now the admin edit

A) edit your language/catalog/manufacturer.php and insert (obvious this is for italian, change in your language)

Code: Select all

$_['entry_meta_description'] = 'Meta Tag Description:';
$_['entry_description']      = 'Descrizione:';
B) change the controller/catalog/manufacturer.php .
add line 264

Code: Select all

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

in the getForm function add (line 272 original file)

Code: Select all

 	$this->data['error_keyword'] = @$this->error['keyword'];
line 288 original file

Code: Select all

		
		$this->load->model('localisation/language');

		$this->data['languages'] = $this->model_localisation_language->getLanguages();
		
		
line 312 original file add

Code: Select all

		if (isset($this->request->post['manufacturer_description'])) {
			$this->data['manufacturer_description'] = $this->request->post['manufacturer_description'];
		} elseif (isset($manufacturer_info)) {
			$this->data['manufacturer_description'] = $this->model_catalog_manufacturer->getManufacturerDescriptions($this->request->get['manufacturer_id']);
		} else {
			$this->data['manufacturer_description'] = array();
		}

and change the function validateForm() adding

Code: Select all

private function validateForm() {
    	$this->load->model('tool/seo_url');
    	
    	if (($this->model_tool_seo_url->validateUrlAlias($this->request->post['keyword'],"manufacturer_id=".$this->request->get['manufacturer_id']))||((strlen($this->request->post['keyword']) < 3))) {
      		$this->error['keyword'] = $this->language->get('error_keyword');
    	}
......
c) change the admin/model/catalog/manufacturer.php in

Code: Select all

<?php
class ModelCatalogManufacturer extends Model {
	public function addManufacturer($data) {
  		$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape(@$data['name']) . "', image = '" . $this->db->escape(basename($data['image'])) . "', sort_order = '" . (int)$data['sort_order'] . "'");
		$manufacturer_id = $this->db->getLastId();

		foreach ($data['category_description'] as $language_id => $value) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_description SET manufacturer_id = '" . (int)$manufacturer_id . "', language_id = '" . (int)$language_id . "', meta_description = '" . $this->db->escape(@$value['meta_description']) . "', description = '" . $this->db->escape(@$value['description']) . "'");
		}
		
		if ($data['keyword']) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'manufacturer_id=" . (int)$manufacturer_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
		}
		
		$this->cache->delete('manufacturer');
	}
	
	public function editManufacturer($manufacturer_id, $data) {
      	$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape(@$data['name']) . "', image = '" . $this->db->escape(basename($data['image'])) . "', sort_order = '" . (int)@$data['sort_order'] . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");

		$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer_description WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");

		foreach ($data['manufacturer_description'] as $language_id => $value) {
			//echo "INSERT INTO " . DB_PREFIX . "manufacturer_description SET manufacturer_id = '" . (int)$manufacturer_id . "', language_id = '" . (int)$language_id . "', meta_description = '" . $this->db->escape(@$value['meta_description']) . "', description = '" . $this->db->escape(@$value['description']) . "'";
			
			$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_description SET manufacturer_id = '" . (int)$manufacturer_id . "', language_id = '" . (int)$language_id . "', meta_description = '" . $this->db->escape(@$value['meta_description']) . "', description = '" . $this->db->escape(@$value['description']) . "'");
		}
		//die();
		
		$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'manufacturer_id=" . (int)$manufacturer_id. "'");
		
		if ($data['keyword']) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = 'manufacturer_id=" . (int)$manufacturer_id . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
		}
		
		$this->cache->delete('manufacturer');
	}
	
	public function deleteManufacturer($manufacturer_id) {
		$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer_description WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
		$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query = 'manufacturer_id=" . (int)$manufacturer_id . "'");
			
		$this->cache->delete('manufacturer');
	}	
	
	public function getManufacturer($manufacturer_id) {
		$query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'manufacturer_id=" . (int)$manufacturer_id . "') AS keyword FROM " . DB_PREFIX . "manufacturer WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
		
		return $query->row;
	}
	
	public function getManufacturerDescriptions($manufacturer_id) {
			$category_description_data = array();

			$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer_description WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");

			foreach ($query->rows as $result) {
				$manufacturer_description_data[$result['language_id']] = array(
					'meta_description' => $result['meta_description'],
					'description'      => $result['description']
				);
			}

			return $manufacturer_description_data;
		}
	
	public function getManufacturers($data = array()) {
		if ($data) {
			$sql = "SELECT * FROM " . DB_PREFIX . "manufacturer";
			
			$sort_data = array(
				'name',
				'sort_order'
			);	
			
			if (in_array(@$data['sort'], $sort_data)) {
				$sql .= " ORDER BY " . $data['sort'];	
			} else {
				$sql .= " ORDER BY name";	
			}
			
			if (@$data['order'] == 'DESC') {
				$sql .= " DESC";
			} else {
				$sql .= " ASC";
			}
			
			if (isset($data['start']) || isset($data['limit'])) {
				$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
			}				
			
			$query = $this->db->query($sql);
		
			return $query->rows;
		} else {
			$manufacturer_data = $this->cache->get('manufacturer');
		
			if (!$manufacturer_data) {
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer ORDER BY name");
	
				$manufacturer_data = $query->rows;
			
				$this->cache->set('manufacturer', $manufacturer_data);
			}
		 
			return $manufacturer_data;
		}
	}
	
	public function getTotalManufacturersByImageId($image_id) {
      	$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "manufacturer WHERE image_id = '" . (int)$image_id . "'");

		return $query->row['total'];
	}

	public function getTotalManufacturers() {
      	$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "manufacturer");
		
		return $query->row['total'];
	}	
}
?>
D) change the view/template/catalog/manufacturer_form.php. Add at line 23

Code: Select all

<?php foreach ($languages as $language) { ?>
      <tr>
        <td width="25%"><?php echo $entry_meta_description; ?></td>
        <td><textarea name="manufacturer_description[<?php echo $language['language_id']; ?>][meta_description]" cols="40" rows="5"><?php echo @$manufacturer_description[$language['language_id']]['meta_description']; ?></textarea>
          <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" style="vertical-align: top;" /><br />
          <?php if (@$error_meta_description[$language['language_id']]) { ?>
          <span class="error"><?php echo $error_meta_description[$language['language_id']]; ?></span>
          <?php } ?></td>
      </tr>
      <tr>
        <td><?php echo $entry_description; ?></td>
        <td><textarea  name="manufacturer_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo @$manufacturer_description[$language['language_id']]['description']; ?></textarea>
          <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" style="vertical-align: top;" />
          <?php if (@$error_description[$language['language_id']]) { ?>
          <span class="error"><?php echo $error_description[$language['language_id']]; ?></span>
          <?php } ?></td>
      </tr>
      <?php } ?>
and at the end of the file this code

Code: Select all

<script type="text/javascript" src="view/javascript/fckeditor/fckeditor.js"></script>
<script type="text/javascript"><!--
var sBasePath = document.location.href.replace(/index\.php.*/, 'view/javascript/fckeditor/');
<?php foreach ($languages as $language) { ?>
var oFCKeditor<?php echo $language['language_id']; ?>          = new FCKeditor('description<?php echo $language['language_id']; ?>');
	oFCKeditor<?php echo $language['language_id']; ?>.BasePath = sBasePath;
	oFCKeditor<?php echo $language['language_id']; ?>.Value	   = document.getElementById('description<?php echo $language['language_id']; ?>').value;
	oFCKeditor<?php echo $language['language_id']; ?>.Width    = '520';
	oFCKeditor<?php echo $language['language_id']; ?>.Height   = '300';
	oFCKeditor<?php echo $language['language_id']; ?>.ReplaceTextarea();
<?php } ?>
//--></script>

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by DannyMacD » Thu Aug 06, 2009 3:04 am

do you have an example of how this would look like a screen shot? if so also a readme for install as i dont know what goes where :(

thank you :)

Active Member

Posts

Joined
Fri Jun 26, 2009 6:39 am

Post by zombyzzz2609 » Thu Aug 06, 2009 10:48 pm

Getting this error. Any ideas?

Fatal error: Class 'Modeltoolseourl' not found in /home2/dmicosta/public_html/onlinestore/system/engine/loader.php on line 28

Thank you

Newbie

Posts

Joined
Wed Jul 08, 2009 12:11 am

Post by Qphoria » Thu Aug 06, 2009 11:41 pm

zombyzzz2609 wrote:Getting this error. Any ideas?

Fatal error: Class 'Modeltoolseourl' not found in /home2/dmicosta/public_html/onlinestore/system/engine/loader.php on line 28

Thank you
Sounds like you are using an old version of OpenCart before it had SEO

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by zombyzzz2609 » Fri Aug 07, 2009 12:20 am

I am using 1.3 and it didn't happen till I made the changes listed in this post.

Newbie

Posts

Joined
Wed Jul 08, 2009 12:11 am

Post by Qphoria » Fri Aug 07, 2009 1:20 am

Do you have this file:
catalog/model/tool/seo_url.php

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by zombyzzz2609 » Fri Aug 07, 2009 10:31 am

Yes I do. However case is wrong.
Class 'Modeltoolseourl' not found is the error.

ModelToolSeoUrl is the name of the class from the file

Does it matter?
I guess I could just rename the class to what it is looking for?
Would that work, or is there a better way?

Thank you.

Newbie

Posts

Joined
Wed Jul 08, 2009 12:11 am

Post by abmcr » Fri Aug 07, 2009 8:57 pm

DannyMacD wrote:do you have an example of how this would look like a screen shot? if so also a readme for install as i dont know what goes where :(

thank you :)
http://www.visualp.eu/ecommerce/apple


For the problem with the model i have not now the code with me....
When possible i send exactly what it is need...

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by abmcr » Sat Aug 08, 2009 12:28 am

I my application the class is

<?php
class ModelToolSeoUrl extends Model {

New member

Posts

Joined
Wed Jun 03, 2009 11:38 pm

Post by imadam » Mon Feb 15, 2010 8:13 am

i have been following the above to add a manufactuere description and have come across an annoying problem using it with version 1.4. i originally got an error saying language_id bit was incorrect as 1.4 stopped using getId(), but then after that i got the following message when trying to view a product or the manufacturers products.

Code: Select all

Error: Table 'openshop.manufacturer_description' doesn't exist
Error No: 1146
SELECT DISTINCT * FROM manufacturer m LEFT JOIN manufacturer_description md ON (m.manufacturer_id = md.manufacturer_id) WHERE m.manufacturer_id = '11' AND md.language_id = '1'
i know this table exsits, i can see it does in phpMyAdmin, but yet opencart can't find it. do i have to perhaps edit a file somewhere else to say what tables exist as manufacturer_description never existed before trying this.

thanks O0
Last edited by imadam on Mon Feb 15, 2010 9:01 pm, edited 2 times in total.

my opencart carpet cleaning woking guildford and Office Cleaning Services in Guildford


Active Member

Posts

Joined
Sun Jan 10, 2010 10:47 pm
Location - Surrey

Post by imadam » Mon Feb 15, 2010 9:23 am

ahhh stupid typo, the script at first spells it as manufacter then refers to it as manufacturer. evening lost to discover that typo :(



edit:

ok i have managed to get it all working great, just one issue. i can save the manufacturer description fine but when i go to edit it the description isn't loaded again. it's saved fine i can see that in phpMyAdmin but it isn't being loaded into the text box.

i think perhaps the issue is on the admin/controller/catalog/manufacturer.php page as i am trying to echo out the $manufacturer_description array and it's always empty.

this is what i have on that page for the description, which is almost identical to how category description is loaded. anyone any ideas?

Code: Select all

		$this->load->model('localisation/language');
		
		$this->data['languages'] = $this->model_localisation_language->getLanguages();		

		if (isset($this->request->post['manufacturer_description'])) {
         $this->data['manufacturer_description'] = $this->request->post['manufacturer_description'];
      } elseif (isset($manufacturer_info)) {
         $this->data['manufacturer_description'] = $this->model_catalog_manufacturer->getManufacturerDescriptions($this->request->get['manufacturer_id']);
      } else {
         $this->data['manufacturer_description'] = array();
      }

my opencart carpet cleaning woking guildford and Office Cleaning Services in Guildford


Active Member

Posts

Joined
Sun Jan 10, 2010 10:47 pm
Location - Surrey

Post by migz » Sat Feb 27, 2010 6:06 pm

Hey, is this working? :)

Active Member

Posts

Joined
Mon Feb 01, 2010 2:13 am

Post by imadam » Mon Mar 01, 2010 5:52 am

migz wrote:Hey, is this working? :)
yes but i am yet to find a solution (though i have stopped looking for now) to the issue with the description not being reloaded, so when i save one with a description it gets saved ok but not reshown when i click to edit it, so when i make a small edit to say the title, a blank description is saved over the old one, very annoying.

my opencart carpet cleaning woking guildford and Office Cleaning Services in Guildford


Active Member

Posts

Joined
Sun Jan 10, 2010 10:47 pm
Location - Surrey

Post by dodokids » Mon Jul 30, 2012 6:53 pm

I use 1.4.9.1 and try to put metatag description and metatag keywords into the manufacturer.
Now when I fill the box with text I receive:
Error: Table 'tuningce_dodokids.manufacturer_description' doesn't exist
Error No: 1146
INSERT INTO manufacturer_description SET category_id = '16', language_id = '0', name = '', meta_keywords = '', meta_description = '', description = ''
Can someone help?

New member

Posts

Joined
Mon Jul 30, 2012 6:50 pm
Who is online

Users browsing this forum: No registered users and 3 guests