JAY BHARAT, software enginer, php programmers, software engineer, jay bharat ,9844542127

 
»
S
I
D
E
B
A
R
«
Magento help customized your own php code with magento data base only.
April 19th, 2009 by admin

If you want your own code using magento data base use follow step:
1. Here I am assuming  your server come magento structure like this : C:\wamp\www\magento
2. Then open file ‘C:\wamp\www\magento\app\design\frontend\default\default\template\page\2columns-right.phtml’ copy below code and paste here after delet all exist code here
2columns-right.phtml.
3.Copy and paste below in the page ‘2columns-right.phtml’ :

<table width="100%" border="2" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" valign="top" bgcolor="#999999">
<?php
if (isset($_GET["categories"])) {
echo "categories=".$_GET["categories"];
}
mysql_connect('localhost','root','');
mysql_select_db('magento1');
$sql = "SELECT * FROM catalog_category_entity_varchar WHERE entity_type_id=9 AND attribute_id =111 AND value != 'Root Catalog'";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res))
{
echo '<br><br><a href=?categories='.$row["entity_id"].'>'.$row["value"].'</a>';
}
?></td>
<td width="85%" bordercolor="#000000" valign="top">
<?php
if (isset($_GET["categories"]))
{
$sql1 = "SELECT * FROM catalog_category_product WHERE category_id =  '".$_GET['categories']."'";
$res1=mysql_query($sql1);
while($row1=mysql_fetch_array($res1))
{
$sql2 = "SELECT value FROM catalog_product_entity_varchar WHERE entity_id =  '".$row1['product_id']."'";
$res2=mysql_query($sql2);
$row2=mysql_fetch_array($res2);
echo "<br><br> name= ".$row2['value'];
$sql3 = "SELECT value FROM catalog_product_entity_decimal WHERE entity_id =  '".$row1['product_id']."'";
$res3=mysql_query($sql3);
$row3=mysql_fetch_array($res3);
echo " , Price= ".$row3['value'];
$sql4 = "SELECT value FROM catalog_product_entity_media_gallery WHERE entity_id =  '".$row1['product_id']."'";
$res4=mysql_query($sql4);
$row4=mysql_fetch_array($res4);
echo "<img src="."media/catalog/product".$row4["value"].">";
$sql5 = "SELECT sku,DATE_FORMAT(created_at,'%Y-%m-%d') as created_at FROM catalog_product_entity WHERE entity_id =  '$row1[product_id]'";
$res5=mysql_query($sql5);
$row5=mysql_fetch_array($res5);
echo "<br>sku= ".$row5['sku'];
echo " , created_at= ".$row5['created_at'];
$sql6 = "SELECT value FROM catalog_product_entity_text WHERE entity_id =  '".$row1['product_id']."'";
$res6=mysql_query($sql6);
$row6=mysql_fetch_array($res6);
echo " , Longdesc= ".$row6['value'];
}
}
?></td>
</tr>
</table>

4. in url write like this
http://localhost/magento/?categories=4


Leave a Reply