<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Open Script Solution&#187; hapus</title>
	<atom:link href="http://www.openscriptsolution.com/tag/hapus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.openscriptsolution.com</link>
	<description>... where solutions for script programming are found ...</description>
	<lastBuildDate>Tue, 31 Jan 2012 03:22:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Handle Duplicate Records by Deleting and Leaving Only One Record from Each Duplicate Records in MySQL Database</title>
		<link>http://www.openscriptsolution.com/2011/07/15/how-to-handle-duplicate-records-by-deleting-and-leaving-only-one-record-from-each-duplicate-records-in-mysql-database/</link>
		<comments>http://www.openscriptsolution.com/2011/07/15/how-to-handle-duplicate-records-by-deleting-and-leaving-only-one-record-from-each-duplicate-records-in-mysql-database/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 15:56:45 +0000</pubDate>
		<dc:creator>Masino Sinaga</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[DISTINCT]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[duplikat]]></category>
		<category><![CDATA[hapus]]></category>
		<category><![CDATA[record]]></category>

		<guid isPermaLink="false">http://www.openscriptsolution.com/?p=1350</guid>
		<description><![CDATA[Have you ever got difficulty when handling the duplicate records in a table in MySQL database, where you want to delete the records and pretty leaves one record from each duplicate records? This usually happens in the table who did not have the primary key, so that it can cause to store the duplicate records. [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever got difficulty when handling the duplicate records in a table in MySQL database, where you want to delete the records and pretty leaves one record from each duplicate records? This usually happens in the table who did not have the primary key, so that it can cause to store the duplicate records. The duplicate records are usually obtained from the data import process that was done repeatedly. Well, the following trick you can use to handle such cases. Quite easy and a little bit outsmart. The first step, you must copy the table structure that stores the duplicate records to another table name (copy table structure only, not including records). The second step, simply copy only one or distinct record from each duplicate records using a single MySQL statement to the copied/destination table. Lastly, the third step, check the results in the destination table. If everything goes smoothly, then delete the original table, and rename back the copied/destination table to the original table name. Curious? <span id="more-1350"></span></p>
<p>For example, you have a table named <strong>table1</strong> which has the structure like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; DESCRIBE `table1`;
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| code        | char(2)     | YES  |     |         |       |
| description | varchar(50) | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+</pre></div></div>

<p>and it has the duplicate records as following:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; select * from table1;
+------+-------------+
| code | description |
+------+-------------+
| 1    | One         |
| 1    | One         |
| 2    | Two         |
| 2    | Two         |
| 3    | Three       |
| 3    | Three       |
| 3    | Three       |
| 4    | Four        |
| 4    | Four        |
| 4    | Four        |
| 4    | Four        |
| 5    | Five        |
| 5    | Five        |
| 5    | Five        |
| 5    | Five        |
| 5    | Five        |
+------+-------------+</pre></div></div>

<p>Let&#8217;s say, you want to delete and leave only one record from each the duplicate records. So the results become like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">+------+-------------+
| code | description |
+------+-------------+
| 1    | One         |
| 2    | Two         |
| 3    | Three       |
| 4    | Four        |
| 5    | Five        |
+------+-------------+</pre></div></div>

<p>So, in order to get that results, copy only the table structure of <strong>table1</strong> to (for example) <strong>table1_copy</strong> using the following SQL statement:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; CREATE TABLE `table1_copy` LIKE `table1`;</pre></div></div>

<p>Afterwards, copy or insert only one record of the duplicate records from <strong>table1</strong> into the <strong>table1_copy</strong> using the following SQL statement:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">INSERT INTO table1_copy
SELECT DISTINCT * FROM table1;</pre></div></div>

<p>Voila&#8230; here is the result:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mysql&gt; SELECT * FROM table1_copy;
+------+-------------+
| code | description |
+------+-------------+
| 1    | One         |
| 2    | Two         |
| 3    | Three       |
| 4    | Four        |
| 5    | Five        |
+------+-------------+</pre></div></div>

<p>Ups, don&#8217;t forget to remove the <strong>table1</strong> table (assuming all the steps above goes smoothly):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">DROP TABLE IF EXISTS `table1`;</pre></div></div>

<p>and then rename the destination table to the original one:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">RENAME TABLE `table1_copy` TO `table1`;</pre></div></div>

<p>It&#8217;s very easy, isn&#8217;t? <img src='http://www.openscriptsolution.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.openscriptsolution.com%2F2011%2F07%2F15%2Fhow-to-handle-duplicate-records-by-deleting-and-leaving-only-one-record-from-each-duplicate-records-in-mysql-database%2F&amp;title=How%20to%20Handle%20Duplicate%20Records%20by%20Deleting%20and%20Leaving%20Only%20One%20Record%20from%20Each%20Duplicate%20Records%20in%20MySQL%20Database" id="wpa2a_2"><img src="http://www.openscriptsolution.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.openscriptsolution.com/2011/07/15/how-to-handle-duplicate-records-by-deleting-and-leaving-only-one-record-from-each-duplicate-records-in-mysql-database/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to Replace the Certain Character in a MySQL Table</title>
		<link>http://www.openscriptsolution.com/2010/08/09/how-to-replace-the-certain-character-in-a-mysql-table/</link>
		<comments>http://www.openscriptsolution.com/2010/08/09/how-to-replace-the-certain-character-in-a-mysql-table/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 07:08:08 +0000</pubDate>
		<dc:creator>Masino Sinaga</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[hapus]]></category>
		<category><![CDATA[REPLACE]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[syntax]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.openscriptsolution.com/?p=1255</guid>
		<description><![CDATA[Have you ever encountered the strange behavior while you were deleting the certain records from a table in MySQL database using an application you build, which those records cannot be deleted? Well, I have! Today, I encountered this problem. This is so weird, since I have never faced this situation before. Well, after doing some [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever encountered the strange behavior while you were deleting the certain records from a table in MySQL database using an application you build, which those records cannot be deleted? Well, I have! Today, I encountered this problem. This is so weird, since I have never faced this situation before. Well, after doing some investigations, this problem obviously caused by one of the primary key fields contains the comma (,) character. Why I am sure about this, because when I replace the comma character for one record, then I re-try to delete that record from that application, voila&#8230;. that record gets successfully deleted. But the main problem is not stop until that. The next question is: How then can I replace all comma characters from the rest of the other records immediately? Just for your information, there are thousand records that contain the comma character. It is impossible to update all the records one by one, even as a matter of fact, you can create a little program/tool in order to implement it using loop method throught the recordset? Well, here is the quick-solution to overcome it. <span id="more-1255"></span></p>
<p>MySQL has provided the great UPDATE SQL syntax for this. You can use this SQL (for instance, I want to replace the comma character inside the <strong>tablename</strong> table with the minus character that located in a field named <strong>thefield</strong>):</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">UPDATE tablename SET `thefield` = REPLACE(`thefield`, ',', '-');</pre></div></div>

<p>Isn&#8217;t easy, huh? <img src='http://www.openscriptsolution.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.openscriptsolution.com%2F2010%2F08%2F09%2Fhow-to-replace-the-certain-character-in-a-mysql-table%2F&amp;title=How%20to%20Replace%20the%20Certain%20Character%20in%20a%20MySQL%20Table" id="wpa2a_4"><img src="http://www.openscriptsolution.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.openscriptsolution.com/2010/08/09/how-to-replace-the-certain-character-in-a-mysql-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Remove Product ID from URL of PrestaShop version 1.2.5</title>
		<link>http://www.openscriptsolution.com/2010/05/04/how-to-remove-product-id-from-url-of-prestashop-version-1-2-5/</link>
		<comments>http://www.openscriptsolution.com/2010/05/04/how-to-remove-product-id-from-url-of-prestashop-version-1-2-5/#comments</comments>
		<pubDate>Tue, 04 May 2010 03:38:46 +0000</pubDate>
		<dc:creator>Masino Sinaga</dc:creator>
				<category><![CDATA[PrestaShop]]></category>
		<category><![CDATA[category id]]></category>
		<category><![CDATA[hapus]]></category>
		<category><![CDATA[product id]]></category>
		<category><![CDATA[ramah URL]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[SEO in PrestaShop]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[URL Friendly]]></category>

		<guid isPermaLink="false">http://www.openscriptsolution.com/?p=1186</guid>
		<description><![CDATA[Have you ever wanted to remove the product id from the URL of your PrestaShop? For instance, by default, PrestaShop uses this URL to display the certain product named ipod-touch: /7-ipod-touch.html instead of /ipod-touch.html. Well, here is the solution how you can make it comes true. I have successfully implemented it into PrestaShop version 1.2.5. [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to remove the product id from the URL of your PrestaShop? For instance, by default, PrestaShop uses this URL to display the certain product named ipod-touch: <strong>/7-ipod-touch.html</strong> instead of <strong>/ipod-touch.html</strong>. Well, here is the solution how you can make it comes true. I have successfully implemented it into PrestaShop version 1.2.5. Please note that before you implement this modification, make sure you have already implemented the similar modification that will <a href="http://www.openscriptsolution.com/2010/05/03/how-to-remove-category-id-from-url-of-prestashop-version-1-2-5/" target="_blank">remove category id</a> from the URL. <span id="more-1186"></span></p>
<ol>
<li>
Make sure that you have already had the <strong>.htaccess</strong> file in your PrestaShop&#8217;s root directory, which has the content like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums
&nbsp;
# URL rewriting module activation
RewriteEngine on
&nbsp;
# URL rewriting rules
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$ /prestashop1250/img/p/$1-$2$3.jpg [L,E]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$ /prestashop1250/img/c/$1$2.jpg [L,E]
RewriteRule ^lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /prestashop1250/product.php?id_product=$3&amp;isolang=$1$5 [L,E]
RewriteRule ^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /prestashop1250/product.php?id_product=$2&amp;isolang=$1$4 [L,E]
RewriteRule ^lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /prestashop1250/category.php?id_category=$2&amp;isolang=$1 [QSA,L,E]
RewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /prestashop1250/product.php?id_product=$2$4 [L,E]
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ /prestashop1250/product.php?id_product=$1$3 [L,E]
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /prestashop1250/category.php?id_category=$1 [QSA,L,E]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ /prestashop1250/cms.php?id_cms=$1 [QSA,L,E]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ /prestashop1250/supplier.php?id_supplier=$1$3 [QSA,L,E]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ /prestashop1250/manufacturer.php?id_manufacturer=$1$3 [QSA,L,E]
RewriteRule ^lang-([a-z]{2})/(.*)$ /prestashop1250/$2?isolang=$1 [QSA,L,E]
&nbsp;
# Catch 404 errors
ErrorDocument 404 /prestashop1250/404.php
&nbsp;
# Remove Category ID from URL. You have to modify also the /classes/Link.php file! Modified by Masino Sinaga, May 3, 2010
RewriteRule ^accessories-ipod$ /prestashop1250/category.php?id_category=3 [QSA,L,E]
RewriteRule ^music-ipods$ /prestashop1250/category.php?id_category=2 [QSA,L,E]
RewriteRule ^laptops$ /prestashop1250/category.php?id_category=1 [QSA,L,E]</pre></div></div>

<p>That <strong>.htaccess</strong> file is generated from the link I mentioned above about. You can generate this .htaccess file from admin panel at <strong>Tools</strong> tab, then choose <strong>Generators</strong> sub-tab, and follow the instructions carefully there. In this example above, I use <strong>prestashop1250</strong> for the domain name. Please adjust it with yours.
</li>
<li>
Add this following code after the last line of that code above:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># Remove Product ID from URL. You have to modify also the /classes/Link.php file! Modified by Masino Sinaga, May 4, 2010
RewriteRule ^music-ipods/ipod-nano\.html(.*)$ product.php?id_product=1$1 [QSA,L,E]
RewriteRule ^music-ipods/ipod-shuffle\.html(.*)$ product.php?id_product=2$1 [QSA,L,E]
RewriteRule ^laptops/macbook-air\.html(.*)$ product.php?id_product=5$1 [QSA,L,E]
RewriteRule ^laptops/macbook\.html(.*)$ product.php?id_product=6$1 [QSA,L,E]
RewriteRule ^music-ipods/ipod-touch\.html(.*)$ product.php?id_product=7$1 [QSA,L,E]
RewriteRule ^accessories-ipod/housse-portefeuille-en-cuir-belkin-pour-ipod-nano-noir-chocolat\.html(.*)$ product.php?id_product=8$1 [QSA,L,E]
RewriteRule ^accessories-ipod/ecouteurs-a-isolation-sonore-shure-se210-blanc\.html(.*)$ product.php?id_product=9$1 [QSA,L,E]</pre></div></div>

<p>It meant that we will adjust the 7 products name: ipod-nano, ipod-shuffle, macbook-air, macbook, ipod-touch, housse-portefeuille-en-cuir-belkin-pour-ipod-nano-noir-chocolat, and ecouteurs-a-isolation-sonore-shure-se210-blanc. In other words, if you have more than 7 products above, you have to define or add your own product one by one into the .htaccess file.
</li>
<li>
Open your <strong>/classes/Link.php</strong> file, find this code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getProductLink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">,</span> <span style="color: #000088;">$alias</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ean13</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	 	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'home'</span> AND <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link_rewrite</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ean13</span> ? <span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ean13</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.html'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
			<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #0000ff;">'product.php?id_product='</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$alias</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span> AND <span style="color: #000088;">$category</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$alias</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ean13</span> ? <span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$ean13</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.html'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
			<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #0000ff;">'product.php?id_product='</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #b1b100;">return</span> _PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #0000ff;">'product.php?id_product='</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>then replace with this following code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getProductLink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">,</span> <span style="color: #000088;">$alias</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ean13</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	 	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'home'</span> AND <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">category</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #666666; font-style: italic;">/*intval($id_product-&gt;id).'-'.*/</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link_rewrite</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ean13</span> ? <span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ean13</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.html'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
			<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #0000ff;">'product.php?id_product='</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$alias</span><span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">allow</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>?<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span> AND <span style="color: #000088;">$category</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #666666; font-style: italic;">/*intval($id_product).'-'.*/</span><span style="color: #000088;">$alias</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ean13</span> ? <span style="color: #0000ff;">'-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$ean13</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.html'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
			<span style="color: #009900;">&#40;</span>_PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #0000ff;">'product.php?id_product='</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #b1b100;">return</span> _PS_BASE_URL_<span style="color: #339933;">.</span>__PS_BASE_URI__<span style="color: #339933;">.</span><span style="color: #0000ff;">'product.php?id_product='</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id_product</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
</ol>
<p>Now you should have the URL without the category and product id in it.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.openscriptsolution.com%2F2010%2F05%2F04%2Fhow-to-remove-product-id-from-url-of-prestashop-version-1-2-5%2F&amp;title=How%20to%20Remove%20Product%20ID%20from%20URL%20of%20PrestaShop%20version%201.2.5" id="wpa2a_6"><img src="http://www.openscriptsolution.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.openscriptsolution.com/2010/05/04/how-to-remove-product-id-from-url-of-prestashop-version-1-2-5/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
