Post by werner » Tue Jul 27, 2010 7:33 pm

Patch Updated
  • 2010-07-28 - Resolved SQL join issues for the product model due to ambiguous "SELECT *" queries.


A complete patch that adds out-of-the-box manufacturer descriptions to a vanilla install source (the opencart archive's 'upload' directory). Apply patch prior to installation. The patch has been fairly well tested. Please let me know if any problems arise.

I hope this patch can get integrated into the source of the next release, since it will add a really basic (in my opinion, an overdue) feature to opencart.

Both the admin section and public frontend have been patched. Manufacturer descriptions are handled in exactly the same way as category descriptions in the admin section.

Minimal database changes were made (all included in the patch of the installation sql). So you don't have to make these changes manually, they are included in the patch. I just list them here for clarity.

The 'name' column has been removed from the manufacturer table:

Code: Select all

CREATE TABLE `oc_manufacturer` (
  `manufacturer_id` int(11) NOT NULL AUTO_INCREMENT,
  `image` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `sort_order` int(3) NOT NULL,
  PRIMARY KEY (`manufacturer_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=11 ;
A new manufacturer_description table was added:

Code: Select all

CREATE TABLE `oc_manufacturer_description` (
  `manufacturer_id` int(11) NOT NULL,
  `language_id` int(11) NOT NULL,
  `name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `meta_keywords` varchar(255) COLLATE utf8_bin NOT NULL,
  `meta_description` varchar(255) COLLATE utf8_bin NOT NULL,
  `description` text COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`manufacturer_id`,`language_id`),
  KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=11 ;
The data for the manufacturer table's name column has been moved to the manufacturer_description table's name column.

I am willing to help to integrate the changes upstream.

For now, I hope it helps someone who desperately needs the same functionality.

Some admin section screenshots:

Image

Image

Have Fun,
Werner

---

PLEASE NOTE: Do not patch your live site or a populated local opencart deployment. Apply patch prior to a new installation only.

NOTE: This patch was also posted to http://code.google.com/p/open-cart/issues/list.

EDIT: Patch File was updated to exclude white-space only changes.

Attachments

Patch that adds manufacturer descriptions to the installation source files.

Last edited by werner on Wed Jul 28, 2010 8:20 pm, edited 5 times in total.

User avatar
Newbie

Posts

Joined
Wed Jan 20, 2010 6:03 pm

Post by werner » Tue Jul 27, 2010 8:50 pm

Someone asked how to apply the patch.
  • Extract the 1.4.8 source archive to some directory.
  • Extract and copy the patch file (opencart148_manufacturer_description.patch) to the same extraction directory.
  • Go to (cd to) that extraction directory. Inside, opencart's "upload" directory should be present.
  • Execute

    Code: Select all

    patch -p0 < opencart148_manufacturer_description.patch
  • Now run the install as usual.
It's that simple.

The patch should output something like this:

Code: Select all

$ patch -p0 < opencart148_manufacturer_description.patch
patching file upload/admin/controller/catalog/manufacturer.php
patching file upload/admin/language/english/catalog/manufacturer.php
patching file upload/admin/model/catalog/manufacturer.php
patching file upload/admin/model/localisation/language.php
patching file upload/admin/view/template/catalog/manufacturer_form.tpl
patching file upload/catalog/controller/product/manufacturer.php
patching file upload/catalog/model/catalog/manufacturer.php
patching file upload/catalog/model/catalog/product.php
patching file upload/catalog/view/theme/default/template/product/manufacturer.tpl
patching file upload/.htaccess.txt
patching file upload/install/opencart.sql
NOTE: These instructions are obviously for Linux. I don't know or use Windows, so I won't be able to help there, sorry.

EDIT: See below for a Windows patch solution. Thanks, OSWorX!
Last edited by werner on Tue Jul 27, 2010 10:13 pm, edited 4 times in total.

User avatar
Newbie

Posts

Joined
Wed Jan 20, 2010 6:03 pm

Post by OSWorX » Tue Jul 27, 2010 9:14 pm

For Windows, a program called WinMerge could be used: http://winmerge.org/

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by mystifier » Tue Jul 27, 2010 11:13 pm

I have got by without this but it did feel like an omission and it would be a great addition to the core.

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by werner » Tue Jul 27, 2010 11:24 pm

I agree, it would be really nice, though, if we could commit code and patches upstream, even only for evaluation.

I could not find any documentation about submitting code to the core. It seems that the forum is the only place...?

How does Opencart's contribution policies work, does anyone know?

User avatar
Newbie

Posts

Joined
Wed Jan 20, 2010 6:03 pm

Post by werner » Wed Jul 28, 2010 5:26 pm

UPDATE: Scratching the OpenCart surface, I realised today that by joining manufacturer descriptions, the product queries give unexpected results. A lot of OpenCart's core queries deliver loads of duplicate column names, which I did not expect (I guess I misread the queries).

Due to the way OpenCart's queries (and joins) are constructed, it's really easy for a joined table to add duplicate columns to the resultset.

E.g. catalog/model/catalog/product.php, I expected (assumed) them to be...

Code: Select all

SELECT DISTINCT p.*
but they are in fact written as...

Code: Select all

SELECT DISTINCT *


which I assume (hope) is for reasons of flexibility as far as extensions (etc) goes...

In either case, I will provide a new patch a bit later, since there are a load of queries that deliver a multitude of duplicate column names in the current OpenCart core :o

User avatar
Newbie

Posts

Joined
Wed Jan 20, 2010 6:03 pm

Post by werner » Wed Jul 28, 2010 8:21 pm

The query problems have been addressed and the new patch can be downloaded from the first original (edited) post.

User avatar
Newbie

Posts

Joined
Wed Jan 20, 2010 6:03 pm

Post by cmerry » Sun Aug 08, 2010 12:40 am

I have three languages in my store. After applying the patch, every product in store show three times. Did you tried this with multiple language store?


User avatar
Active Member

Posts

Joined
Sat Jul 17, 2010 8:42 pm

Post by CodeBits » Tue Aug 10, 2010 4:09 pm

I never understood the reason to have the ability to upload an image for a Manufacturer when it's not being displayed, or not having the means to add a Manufacturer description. This patch I'm not sure is refined to work yet by reading this post, not to mention if it was or is working properly it must be installed prior to installation of your store.

For those of you who have already installed your shop and would like to display a Manufacturer logo and or add a description on the Manufacturer pages you can do it with a little bit of PHP code in the catalog/view/theme/default/template/product/manufacturer.tpl file. In fact you can use this for a multitude of display control options based on the URL Server request.

Easiest when using SEO URLs as in the second line example but you don't have to.
Here's a sample code;

Code: Select all

<?php 
    if ($_SERVER['REQUEST_URI'] == 'stores/index.php?route=product/manufacturer&manufacturer_id=8'){ 
	echo "<div id=\"css\">Your Text Goes Here - and or <img src=\"http://link-to-your-image/manufacturerjpg\" width=\"100\" height=\"100\" border=\"0\" alt=\"Apple\">";
    } elseif ($_SERVER['REQUEST_URI'] == '/stores/apple){
	echo "<div id=\"css\">Your Text Goes Here - and or <img src=\"http://link-to-your-image/manufacturerjpg\" width=\"100\" height=\"100\" border=\"0\" alt=\"Apple\">";
    } else {
	echo "You can put any code you want in the echo just be sure to escape your quotes [ \" \" ] ";
	} ?>
You can build a library with variable names like $apple [more complex and not for the novice] and use echo to call it or a real easy way just make .tpl pages and use a PHP include to call it like shown below. Below is the easiest and cleanest way to do it.

Code: Select all

<?php 
    if ($_SERVER['REQUEST_URI'] == '/stores/apple'){ 
	include("/stores/library/apple.tpl");
    } elseif ($_SERVER['REQUEST_URI'] == '/stores/sony'){
	include("/stores/library/sony.tpl");
    } elseif ($_SERVER['REQUEST_URI'] == '/stores/jvc'){
	include("/stores/library/jvc.tpl");
    } elseif ($_SERVER['REQUEST_URI'] == '/stores/panasonic'){
	include("/stores/library/panasonic.tpl");
    } else {
	include(" ");
	} ?>
With a little bit of creativity and the power of PHP you don't always need modules to make thing happen.

User avatar
Active Member

Posts

Joined
Fri Jun 05, 2009 3:16 am

Post by cmerry » Tue Aug 10, 2010 8:13 pm

Thank you CodeBits, but again, what if I have multilanguage store? This solution works, if you have just one language in store.


User avatar
Active Member

Posts

Joined
Sat Jul 17, 2010 8:42 pm

Post by CodeBits » Wed Aug 11, 2010 12:24 am

cmerry wrote:Thank you CodeBits, but again, what if I have multilanguage store? This solution works, if you have just one language in store.
It will work with multi-language you just need to write a server request for the page name in that language.
For example stores/library/apple in German I believe apple would be apfel. I know this is more work but running a multi-language store is more work. This is where a library with variable names would be better to use. This would be something very much like OC's language files.

User avatar
Active Member

Posts

Joined
Fri Jun 05, 2009 3:16 am

Post by OSWorX » Wed Aug 11, 2010 1:32 am

CodeBits wrote:.. I know this is more work but running a multi-language store is more work. ..
Not really true!
If the framework is good, mulitlanguage sites are no problem.
The only additional work are the translations.

And coming back to your
CodeBits wrote:With a little bit of creativity and the power of PHP you don't always need modules to make thing happen.
We are living and working in a dynamic world.
Doing like you say is similiar what we have done nearly 16 years ago: static html pages.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by CodeBits » Wed Aug 11, 2010 2:04 am

OSWorX wrote: Not really true!
If the framework is good, mulitlanguage sites are no problem.
The only additional work are the translations.
Still equates to more work.
OSWorX wrote:And coming back to your
We are living and working in a dynamic world.
Doing like you say is similiar what we have done nearly 16 years ago: static html pages.
I disagree, PHP is dynamic in nature, building a library is dynamic and no different than the OC language file library's. Making a .tpl file for this is no different than OC's .tpl files, both are dynamically called to the display. Before we had databases to use we used flat-files, before there was PHP we used Perl CGI to create the dynamic environment. OC's language files are nothing more than a fancy flat-file of data.

I offer this solution as a work around for those who want to add content and images for their manufactures and already have their shops installed. I didn't put it up to debate on it's dynamic validity, it's simply an option for those who choose to use it.

User avatar
Active Member

Posts

Joined
Fri Jun 05, 2009 3:16 am

Post by xrgb » Fri Aug 13, 2010 4:09 am

Friends, pls help me to install this patch in Windows! Could you describe installation process in details? I can't understand how to use WinMerge and patch-file to update my OpenCart..

Newbie

Posts

Joined
Fri Aug 13, 2010 3:57 am

Post by mfrerebeau » Fri Aug 13, 2010 7:31 pm

Hello

I'm new with OpenCart and I try to search some informations and tricks.
Your mod is very interesting ! That's exactly what I searched, but I'm french and, actually I'm on 1.4.7.

Is your method can be used on 1.4.7 ? Is-it really different on this point ?

Thanks for your answers.

Single we go faster, together we go more away...


User avatar
New member

Posts

Joined
Fri Aug 13, 2010 5:29 pm
Location - France

Post by jaajaa » Sun Aug 15, 2010 10:52 pm

thanks for the help CodeBits - with a bit of fiddling (and a minor correction), I managed to get it working on my site. Thankfully, I only have 2 manufacturers so it was straightforward. I'm still baffled as to why this feature isn't a default one for this cart. Then again, I'm amazed at the number of community contributions that are essential but still not part of the main source code.

Newbie

Posts

Joined
Tue Aug 03, 2010 10:48 am

Post by mfrerebeau » Tue Aug 17, 2010 11:50 pm

mfrerebeau wrote:Hello

I'm new with OpenCart and I try to search some informations and tricks.
Your mod is very interesting ! That's exactly what I searched, but I'm french and, actually I'm on 1.4.7.

Is your method can be used on 1.4.7 ? Is-it really different on this point ?

Thanks for your answers.
Ok, I answer to me in case it interests someone... ;)

It's run with OC 1.4.7 too !
I apply diff by hand because I want to apply this addon on a exist store...

Just one file isn't compatible : catalog/model/catalog/product.php
OC 1.4.7 don't have meta_keywords fields... So SQL request must be changes.
Just delete all occurrence of this : "pd.meta_keywords AS meta_keywords, "
That's all.

Thanks a lot ! It have been a good practice for me to understand how OC run ! :D

Single we go faster, together we go more away...


User avatar
New member

Posts

Joined
Fri Aug 13, 2010 5:29 pm
Location - France

Post by mfrerebeau » Wed Aug 25, 2010 6:19 am

Hello,

After more tests I see that when we have more than 1 language, all products are double...
I haven't seen before because I had delete english language to maintain French.

To resolve the problem I put the SQL word DISTINCT behind all SELECT that was changed in catalog/model/catalog/product.php

This extension is very interesting. But I hope there will not appear any other surprise :-[

Good night ;)

Single we go faster, together we go more away...


User avatar
New member

Posts

Joined
Fri Aug 13, 2010 5:29 pm
Location - France

Post by SapporoGuy » Mon Dec 20, 2010 1:57 am

looky here.

Hmmm, Why wasn't something like this put into 1.4.9?
Well, better yet, will this be in 1.5?

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by tobiasbp » Fri Feb 04, 2011 12:53 am

CodeBits wrote:... or a real easy way just make .tpl pages and use a PHP include to call it like shown below.
Excellent suggestion. I'll do just that. This solution won't break on the next OC upgrade. Thank you for your thoughts on this.

Like other users here, I wonder why this (manufacturer description) is not in the OC core? I just looked at the demo of 1.5.0 and there is still no description for manufacturers?

Was this feature ever suggested to the developer(s)? Any official reply?

My OpenCart store selling scandinavian mid century stuff to Japan:
北欧ヴィンテージ雑貨のwww.sonotoki.jp


Newbie

Posts

Joined
Tue Sep 07, 2010 4:14 am
Who is online

Users browsing this forum: No registered users and 92 guests