<?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>cogitsolution</title>
	<atom:link href="http://www.cogitsolutions.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cogitsolutions.com/blog</link>
	<description>Customized, Optimized, Generalized Solutions</description>
	<lastBuildDate>Fri, 05 Mar 2010 11:31:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Model View Controller MVC</title>
		<link>http://www.cogitsolutions.com/blog/2010/03/model-view-controller-mvc/</link>
		<comments>http://www.cogitsolutions.com/blog/2010/03/model-view-controller-mvc/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 11:29:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Development - PHP]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/2010/03/model-view-controller-mvc/</guid>
		<description><![CDATA[by Kevin Waterson from http://www.phpro.org/tutorials/Model-View-Controller-MVC.html
Abstract
Model View Controller.
This tutorial will take you from the beginning to the end of building a MVC framework. The object is not soley to produce the finished MVC framework, although that will happen, but to demonstrate how MVC works and some of the concepts that lay behind it..
What is MVC?
MVC is [...]]]></description>
			<content:encoded><![CDATA[<p>by Kevin Waterson from http://www.phpro.org/tutorials/Model-View-Controller-MVC.html</p>
<p>Abstract</p>
<p>Model View Controller.</p>
<p>This tutorial will take you from the beginning to the end of building a MVC framework. The object is not soley to produce the finished MVC framework, although that will happen, but to demonstrate how MVC works and some of the concepts that lay behind it..<br />
What is MVC?</p>
<p>MVC is a design pattern. A Design pattern is a code structure that allows for common coding frameworks to be replicated quickly. You might think of a design pattern as a skeleton or framework on which your application will be built.</p>
<p>In the MVC framework that is created in this tutorial, several key points will be raised. The first is the frameworks needs a single point of entry, ie: index.php. This is where all access to the site must be controlled from. To ensure that a single point of entry is maintained, htaccess can be utilized to ensure no other file may be accessed, and that we hide the index.php file in the url. Thus creating SEO and user friendly URL&#8217;s.</p>
<p>It is beyond the scope of this tutorial to show how to set up htaccess and mod_rewrite and more information on these can be gained from the Apache manual. The .htaccess file itself looks like this.<br />
RewriteEngine on</p>
<p>RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d</p>
<p>RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]</p>
<p>The .htaccess file will permit access to the site via urls such as<br />
http://www.example.com/news/show</p>
<p>If you do not have mod_rewrite available, the entry to the site will be the same, except that the URL will contain the values needed such as:<br />
http://www.example.com/index.php?rt=news/show<br />
The Site Structure</p>
<p>In this tutorial several directories are required to hold the various components that make up the MVC framework. The index.php and the .htaccess files will, of course, reside at the top level. We will need a directory to hold the application code, and directories for the model view and controllers. The site structure should look like this:<br />
 html<br />
        application<br />
        controller<br />
        includes<br />
        model<br />
        views<br />
 .htaccess<br />
 index.php<br />
The Index File</p>
<p>As previously mentioned, the index.php file is our single point of access. As such, it provides the ideal space for declaring variables and site wide configurations. It is in this file that we will also call a helper file to initialize a few values. This file will be called init.php and it will be placed in includes directory as shown in the direcory structure. The index file therefore, will begin like this:</p>
<p><?php</p>
<p> /*** error reporting on ***/<br />
 error_reporting(E_ALL);</p>
<p> /*** define the site path constant ***/<br />
 $site_path = realpath(dirname(__FILE__));<br />
 define (&#8217;__SITE_PATH&#8217;, $site_path);</p>
<p> /*** include the init.php file ***/<br />
 include &#8216;includes/init.php&#8217;;</p>
<p>?></p>
<p>The index.php file so far only sets the error reporting, includes the init file, and defines the site path constant. With this file in place, and the .htaccess file we can begin to build the registry. In this MVC framework, the registry object is passed to other objects and contains site wide variables without the the use globals. To create a new registry object, we use the init.php file in the includes directory.</p>
<p>Of course, to create new object we need to include the registry class definition file. During the building of the MVC framework we will be including the application class files directly. Any PHP class definition files which are used by the model will be autoloaded as they can become quite cumbersome with larger applications. To alleviate some of this PHP has the __autoload function to help us out. After the application includes, the __autoload function will immediately follow to load class definition files automatically when they are required by the system. That is, when the new keyword is used. The class definitions will be stored in a directory called model. The includes/init.php file should now look like this.</p>
<p><?php</p>
<p> /*** include the controller class ***/<br />
 include __SITE_PATH . &#8216;/application/&#8217; . &#8216;controller_base.class.php&#8217;;</p>
<p> /*** include the registry class ***/<br />
 include __SITE_PATH . &#8216;/application/&#8217; . &#8216;registry.class.php&#8217;;</p>
<p> /*** include the router class ***/<br />
 include __SITE_PATH . &#8216;/application/&#8217; . &#8216;router.class.php&#8217;;</p>
<p> /*** include the template class ***/<br />
 include __SITE_PATH . &#8216;/application/&#8217; . &#8216;template.class.php&#8217;;</p>
<p> /*** auto load model classes ***/<br />
    function __autoload($class_name) {<br />
    $filename = strtolower($class_name) . &#8216;.class.php&#8217;;<br />
    $file = __SITE_PATH . &#8216;/model/&#8217; . $filename;</p>
<p>    if (file_exists($file) == false)<br />
    {<br />
        return false;<br />
    }<br />
  include ($file);<br />
}</p>
<p> /*** a new registry object ***/<br />
 $registry = new registry;</p>
<p>?></p>
<p>Here is should be noted that the autoload function uses a naming convention for the class definition files to be included. They must all follow the convention of ending in .class.php and the class name must be that of the .class.php file name. So that to create a new &#8220;news&#8221; object the class definition file name must be news.class.php and the class must be named &#8220;news&#8221;. With these files in place we are well on the way, however our MVC does not do anything yet. In fact, if you tried to access the index.php file now, you would get many errors about missing files. Mostly from the files in the application directory. So, lets begin by creating those files each can be blank or simply contain<br />
<?php</p>
<p>?></p>
<p>The files to create in the application directory are:</p>
<p>    * controller_base.class.php<br />
    * registry.class.php<br />
    * router.class.php<br />
    * template.class.php</p>
<p>Note that although these files are not autoloaded, we have still maintained the same naming convention by calling the files .class.php<br />
The Registry</p>
<p>The registry is an object where site wide variables can be stored without the use of globals. By passing the registry object to the controllers that need them, we avoid pollution of the global namespace and render our variables safe. We need to be able to set registry variables and to get them. The php magic functions __set() and __get() are ideal for this purpose. So, open up the registry.class.php in the applications directory and put the following code in it:</p>
<p><?php</p>
<p>Class Registry {</p>
<p> /*<br />
 * @the vars array<br />
 * @access private<br />
 */<br />
 private $vars = array();</p>
<p> /**<br />
 *<br />
 * @set undefined vars<br />
 *<br />
 * @param string $index<br />
 *<br />
 * @param mixed $value<br />
 *<br />
 * @return void<br />
 *<br />
 */<br />
 public function __set($index, $value)<br />
 {<br />
        $this->vars[$index] = $value;<br />
 }</p>
<p> /**<br />
 *<br />
 * @get variables<br />
 *<br />
 * @param mixed $index<br />
 *<br />
 * @return mixed<br />
 *<br />
 */<br />
 public function __get($index)<br />
 {<br />
        return $this->vars[$index];<br />
 }</p>
<p>}</p>
<p>?></p>
<p>With the registry in place, our system is working. It does not do anything or display anything, but we have a functional system. The __set() and __get() magic function now allow us to set variables within the registry and store them there. Now to add the Model and router classes.<br />
The Model</p>
<p>The Model is the &#8220;M&#8221; in MVC. The model is where business logic is stored. Business logic is loosely defined as database connections or connections to data sources, and provides the data to the controller. As I am a fan of CAV (Controller Action View) we will blur the line between the Model and Controller. This is not strictly how MVC should work, but this is PHP baby. Our database connection is a simple singleton design pattern and resides in the classes directory and can be called statically from the controller and set in the registry. Add this code to the init.php file we created earlier.</p>
<p><?php</p>
<p> /*** create the database registry object ***/<br />
 $registry->db = db::getInstance();</p>
<p>?></p>
<p>Like all registry members, the database is now globally availabe to our scripts. As the class is a singleton we always get the same instance back. Now that registry objects can be created a method of controlling what is loaded is needed.<br />
The Router</p>
<p>The router class is responsible for loading up the correct controller. It does nothing else. The value of the controller comes from the URL. The url will look a like this:<br />
http://www.example.com/index.php?rt=news<br />
or if you have htaccess amd mod_rewrite working like this:<br />
http://www.example.com/news</p>
<p>As you can see, the route is the rt variable with the value of news. To begin the router class a few things need to be set. Now add this code to the router.class.php file in the application directory.</p>
<p><?php</p>
<p>class router {<br />
 /*<br />
 * @the registry<br />
 */<br />
 private $registry;</p>
<p> /*<br />
 * @the controller path<br />
 */<br />
 private $path;</p>
<p> private $args = array();</p>
<p> public $file;</p>
<p> public $controller;</p>
<p> public $action;</p>
<p> function __construct($registry) {<br />
        $this->registry = $registry;<br />
 }</p>
<p>So it does not look like much yet but is enough to get us started. We can load the router into the registry also. Add this code to the index.php file.</p>
<p> /*** load the router ***/<br />
 $registry->router = new router($registry);</p>
<p>Now that the router class can be loaded, we can continue with the router class by adding a method to set the controller directory path. Add this block of code to the router.class.php file.</p>
<p><?php<br />
 /**<br />
 *<br />
 * @set controller directory path<br />
 *<br />
 * @param string $path<br />
 *<br />
 * @return void<br />
 *<br />
 */<br />
 function setPath($path) {</p>
<p>        /*** check if path i sa directory ***/<br />
        if (is_dir($path) == false)<br />
        {<br />
                throw new Exception (&#8217;Invalid controller path: `&#8217; . $path . &#8216;`&#8217;);<br />
        }<br />
        /*** set the path ***/<br />
        $this->path = $path;<br />
}</p>
<p>And to set the controller path in the registry is a simple matter of adding this line to the index.php file</p>
<p> /*** set the path to the controllers directory ***/<br />
 $router->setPath (__SITE_PATH . &#8216;controller&#8217;);</p>
<p>With the controller path set we can load the controller. We will create a method to called loader() to get the controller and load it. This method will call a getController() method that will decide which controller to load. If a controller is not found then it will default back to the index. The loader method looks like this.</p>
<p><?php</p>
<p> /**<br />
 *<br />
 * @load the controller<br />
 *<br />
 * @access public<br />
 *<br />
 * @return void<br />
 *<br />
 */<br />
 public function loader()<br />
 {<br />
        /*** check the route ***/<br />
        $this->getController();</p>
<p>        /*** if the file is not there diaf ***/<br />
        if (is_readable($this->file) == false)<br />
        {<br />
                echo $this->file;<br />
                die (&#8217;404 Not Found&#8217;);<br />
        }</p>
<p>        /*** include the controller ***/<br />
        include $this->file;</p>
<p>        /*** a new controller class instance ***/<br />
        $class = $this->controller . &#8216;Controller_&#8217;;<br />
        $controller = new $class($this->registry);</p>
<p>        /*** check if the action is callable ***/<br />
        if (is_callable(array($controller, $this->action)) == false)<br />
        {<br />
                $action = &#8216;index&#8217;;<br />
        }<br />
        else<br />
        {<br />
                $action = $this->action;<br />
        }<br />
        /*** run the action ***/<br />
        $controller->$action();<br />
 }</p>
<p>The getController method that the loader() method calls does the work. By taking the route variables from the url via $_GET['rt'] it is able to check if a contoller was loaded, and if not default to index. It also checks if an action was loaded. An action is a method within the specified controller. If no action has been declared, it defaults to index. Add the getController method to the router.class.php file.</p>
<p><?php<br />
 /**<br />
 *<br />
 * @get the controller<br />
 *<br />
 * @access private<br />
 *<br />
 * @return void<br />
 *<br />
 */<br />
private function getController() {</p>
<p>        /*** get the route from the url ***/<br />
        $route = (empty($_GET['rt'])) ? &#8221; : $_GET['rt'];</p>
<p>        if (empty($route))<br />
        {<br />
                $route = &#8216;index&#8217;;<br />
        }<br />
        else<br />
        {<br />
                /*** get the parts of the route ***/<br />
                $parts = explode(&#8217;/', $route);<br />
                $this->controller = $parts[0];<br />
                if(isset( $parts[1]))<br />
                {<br />
                        $this->action = $parts[1];<br />
                }<br />
        }</p>
<p>        if (empty($this->controller))<br />
        {<br />
                $this->controller = &#8216;index&#8217;;<br />
        }</p>
<p>        /*** Get action ***/<br />
        if (empty($this->action))<br />
        {<br />
                $this->action = &#8216;index&#8217;;<br />
        }</p>
<p>        /*** set the file path ***/<br />
        $this->file = $this->path .&#8217;/&#8217;. $this->controller . &#8216;.php&#8217;;<br />
}<br />
?><br />
The Controller</p>
<p>The Contoller is the C in MVC. The base controller is a simple abstract class that defines the structure of all controllers. By including the registry here, the registry is available to all class that extend from the base controller. An index() method has also been included in the base controller which means all controller classes that extend from it must have an index() method themselves. Add this code to the controller.class.php file in the application directory.</p>
<p><?php</p>
<p>Abstract Class baseController {</p>
<p>/*<br />
 * @registry object<br />
 */<br />
protected $registry;</p>
<p>function __construct($registry) {<br />
        $this->registry = $registry;<br />
}</p>
<p>/**<br />
 * @all controllers must contain an index method<br />
 */<br />
abstract function index();<br />
}</p>
<p>?></p>
<p>Whilst we are in the controller creating mood, we can create an index controller and a blog controller. The index controller is the sytem default and it is from here that the first page is loaded. The blog controller is for an imaginary blog module. When the blog module is specified in the URL<br />
http://www.example.com/blog<br />
then the index method in the blog controller is called. A view method will also be created in the blog controller and when specified in the URL<br />
http://www.example.com/blog/view<br />
then the view method in the blog controller will be loaded. First lets see the index controller. This will reside in the controller directory.</p>
<p><?php</p>
<p>class indexController extends baseController {</p>
<p>public function index() {<br />
    /*** set a template variable ***/<br />
        $this->registry->template->welcome = &#8216;Welcome to PHPRO MVC&#8217;;</p>
<p>    /*** load the index template ***/<br />
        $this->registry->template->show(&#8217;index&#8217;);<br />
}</p>
<p>}</p>
<p>?></p>
<p>The indexController class above shows that the indexController extends the baseController class, thereby making the registry available to it without the need for global variables. The indexController class also contains the mandatory index() method that ll controllers must have. Within itn index() method a variable named &#8220;welcome&#8221; is set in the registry. This variable is available to the template when it is loaded via the template->show() method.</p>
<p>The blogController class follows the same format but has has one small addition, a view() method. The view() method is an example of how a method other than the index() method may be called. The view method is loaded via the URL<br />
http://www.example.com/blog/view</p>
<p><?php</p>
<p>Class blogController Extends baseController {</p>
<p>public function index() {<br />
        $this->registry->template->blog_heading = &#8216;This is the blog Index&#8217;;<br />
        $this->registry->template->show(&#8217;blog_index&#8217;);<br />
}</p>
<p>public function view(){</p>
<p>        /*** should not have to call this here&#8230;. FIX ME ***/</p>
<p>        $this->registry->template->blog_heading = &#8216;This is the blog heading&#8217;;<br />
        $this->registry->template->blog_content = &#8216;This is the blog content&#8217;;<br />
        $this->registry->template->show(&#8217;blog_view&#8217;);<br />
}</p>
<p>}<br />
?><br />
The View</p>
<p>The View, as you might have guessed, is the V in MVC. The View contains code that relates to presentation and presentation logic such as templating and caching. In the controller above we saw the show() method. This is the method that calls the view. The major component in the PHPRO MVC is the template class. The template.class.php file contains the class definition. Like the other classes, it has the registry available to it and also contains a __set() method in which template variables may be set and stored.</p>
<p>The show method is the engine room of the view. This is the method that loads up the template itself, and makes the template variables available. Some larger MVC&#8217;s will implement a template language that adds a further layer of abstraction from PHP. Added layers mean added overhead. Here we stick with the speed of PHP within the template, yet all the logic stays outside. This makes it easy for HTML monkies to create websites without any need to learn PHP or a template language. The template.class.php file looks like this:</p>
<p><?php</p>
<p>Class Template {</p>
<p>/*<br />
 * @the registry<br />
 * @access private<br />
 */<br />
private $registry;</p>
<p>/*<br />
 * @Variables array<br />
 * @access private<br />
 */<br />
private $vars = array();</p>
<p>/**<br />
 *<br />
 * @constructor<br />
 *<br />
 * @access public<br />
 *<br />
 * @return void<br />
 *<br />
 */<br />
function __construct($registry) {<br />
        $this->registry = $registry;</p>
<p>}</p>
<p> /**<br />
 *<br />
 * @set undefined vars<br />
 *<br />
 * @param string $index<br />
 *<br />
 * @param mixed $value<br />
 *<br />
 * @return void<br />
 *<br />
 */<br />
 public function __set($index, $value)<br />
 {<br />
        $this->vars[$index] = $value;<br />
 }</p>
<p>function show($name) {<br />
        $path = __SITE_PATH . &#8216;/views&#8217; . &#8216;/&#8217; . $name . &#8216;.php&#8217;;</p>
<p>        if (file_exists($path) == false)<br />
        {<br />
                throw new Exception(&#8217;Template not found in &#8216;. $path);<br />
                return false;<br />
        }</p>
<p>        // Load variables<br />
        foreach ($this->vars as $key => $value)<br />
        {<br />
                $$key = $value;<br />
        }</p>
<p>        include ($path);<br />
}</p>
<p>}</p>
<p>?><br />
Templates</p>
<p>The templates themselves are basically HTML files with a little PHP embedded. Do not let the separation Nazi&#8217;s try to tell you that you need to have full seperation of HTML and PHP. Remember, PHP is an embeddable scripting language. This is the sort of task it is designed for and makes an efficient templating language. The template files belong in the views directory. Here is the index.php file.</p>
<h2><?php echo $welcome; ?></h2>
<p>Well, that was pretty amazing.. Now for the blog_index.php file.</p>
<h2><?php echo $blog_heading; ?></h2>
<p>And finally the blog_view.php file..</p>
<h2><?php echo $blog_heading; ?></h2>
<p><?php echo $blog_content; ?></p>
<p>In the above template files note that the variable names in the templates, match the template variables created in the controller.<br />
Download Source</p>
<p>The full source code for this MVC Framework is available for download here.<br />
http://www.phpro.org/downloads/mvc-0.0.4.tar.gz<br />
Update</p>
<p>Due to the populariity of this tutorial and the framework, a small side project has been spawned that builds on this tutorial and adds some practical functionality. Users are recommended to get the basics in this tutorial and move on to the next level. See more at http://sevenkevins.com and see how simple and easy MVC and application development can be.<br />
Conclusion</p>
<p>It is hoped that you have found some insight into how MVC works whilst reading this tutorial. The MVC Framework you have build here should be used as a guide only, although it is a fully functional implementation, it is left to the user to build on it and take it to new hights. If you are using this MVC in any way, or have corrections or improvements, simply contact us.<br />
Credits</p>
<p>Thanks to Bill Hernandez of Plano, Texas for errata. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2010/03/model-view-controller-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import images into Magento databse without using Magento core files.</title>
		<link>http://www.cogitsolutions.com/blog/2010/02/import-images-into-magento-databse-without-using-magento-core-files/</link>
		<comments>http://www.cogitsolutions.com/blog/2010/02/import-images-into-magento-databse-without-using-magento-core-files/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 12:13:59 +0000</pubDate>
		<dc:creator>Manoj Ninave</dc:creator>
				<category><![CDATA[Web Development - PHP]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/2010/02/import-images-into-magento-databse-without-using-magento-core-files/</guid>
		<description><![CDATA[here code is to import images into magento databse without using any core files.
this is for product&#8217;s images. you can modify it for gallery images also.
here all the images took from media/import and copied to that perticular directory.
you can find here,how images created there directory structure.
if images name is example.gif,then will create directory structure like [...]]]></description>
			<content:encoded><![CDATA[<p>here code is to import images into magento databse without using any core files.<br />
this is for product&#8217;s images. you can modify it for gallery images also.<br />
here all the images took from media/import and copied to that perticular directory.</p>
<p>you can find here,how images created there directory structure.</p>
<p>if images name is example.gif,then will create directory structure like e/x/example.gif.<br />
that is means this images will copy to media/catalog/product/e/x/example.gif<br />
and the value /e/x/example.gif will insert into table catalog_product_entity_varchar.you can see this image at fronend to that perticular product.Actaully i did script to imaport product with catagory,attribute,images,description&#8230;. etc<br />
it is nothing but a cron job.i took only import images part from my script.</p>
<p>$LargeProductImageURL=$LargeImageURL!=&#8221;"?basename($allData[$key]-&gt;LargeImageURL):&#8221;";</p>
<p>$first_2_letter = substr(&#8221;$LargeProductImageURL&#8221;, 0,2);<br />
$first_letter = substr(&#8221;$first_2_letter&#8221;, 0,1);<br />
$second_letter = substr(&#8221;$first_2_letter&#8221;, -1);<br />
$product_image =&#8221;/&#8221;.$first_letter.&#8221;/&#8221;.$second_letter.&#8221;/&#8221;.$LargeProductImageURL;</p>
<p>$product_path=$media_path.&#8221;".$slash.&#8221;catalog\product&#8221;;<br />
$import_images=$media_path.&#8221;".$slash.&#8221;import&#8221;.$slash.&#8221;".$LargeProductImageURL;<br />
$mypath1=$product_path.&#8221;".$slash.&#8221;".$first_letter;<br />
if(!is_dir($mypath1))<br />
{<br />
mkdir($mypath1,0777,TRUE);<br />
}<br />
$mypath2=$product_path.&#8221;".$slash.&#8221;".$first_letter.&#8221;".$slash.&#8221;".$second_letter;<br />
if(!is_dir($mypath2))<br />
{<br />
mkdir($mypath2,0777,TRUE);<br />
}<br />
//copy ( string $source , string $dest [, resource $context ] )<br />
$Image_dest=$mypath2.&#8221;".$slash.&#8221;".$LargeProductImageURL;<br />
@copy($import_images,$Image_dest);</p>
<p>#####check Is images are ready for copy or not<br />
if (file_exists($import_images)) {<br />
$product_image = $product_image;<br />
}<br />
else {<br />
$product_image=&#8221;no_selection&#8221;;<br />
}<br />
#######<br />
$UrlKey = strtolower(str_replace(&#8221; &#8220;,&#8221;-&#8221;,$PName));<br />
$URL_path= $PName.&#8221;.html&#8221;;</p>
<p>/*if(empty($LargeProductImageURL))<br />
{$product_image=&#8221;no_selection&#8221;;}*/</p>
<p>$db_obj-&gt;query(&#8221;INSERT INTO catalog_product_entity_varchar(entity_type_id, attribute_id,store_id,entity_id,value) VALUES<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;56&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$PName.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;82&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$UrlKey.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;469&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;2&#8242;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;67&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$PName.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;69&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$PName.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;70&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$product_image.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;71&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$product_image.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;72&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$product_image.&#8221;&#8216;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;86&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8221;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;90&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8221;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;92&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;container2&#8242;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;95&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8221;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;96&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8221;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;97&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8221;),<br />
(&#8217;&#8221;.$catalog_product.&#8221;&#8216;,&#8217;83&#8242;,&#8217;0&#8242;,&#8217;&#8221;.$entity_id.&#8221;&#8216;,&#8217;&#8221;.$URL_path.&#8221;&#8216;)&#8221;, $db_conect);</p>
<p>regard<br />
Manoj Ninave</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2010/02/import-images-into-magento-databse-without-using-magento-core-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Unzip/Extract zip file into one directory.</title>
		<link>http://www.cogitsolutions.com/blog/2010/02/how-to-unzipextract-zip-file-into-one-directory/</link>
		<comments>http://www.cogitsolutions.com/blog/2010/02/how-to-unzipextract-zip-file-into-one-directory/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 08:38:33 +0000</pubDate>
		<dc:creator>Manoj Ninave</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/2010/02/how-to-unzipextract-zip-file-into-one-directory/</guid>
		<description><![CDATA[ini_set(&#8217;memory_limit&#8217;,'800M&#8217;);
set_time_limit(36000);
/**
*	@Module to Extract folder in one directory
*	@package general
*	@copyright Copyright 2010-11 COG IT Solutions Development Team
*	@Author: Mr. Manoj M.Ninave
**/
//create media/import directory in root dir
$dir = $_SERVER['DOCUMENT_ROOT'].&#8221;/media/import&#8221;;
$filename = $dir.&#8221;/ABC.zip&#8221;;//destination
$zip_file = &#8220;http://www.yourssite.com/ABC.zip&#8221;;//source
$contents = file_get_contents($zip_file);
//echo $contents;
$handle = fopen($filename, &#8220;w+&#8221;);
fwrite($handle,$contents);
fclose($handle);
$zip = zip_open($filename);
if ($zip)
{
  while ($zip_entry = zip_read($zip))
  {
	$zipEntry = zip_entry_name($zip_entry);
	$zipEntryFile = substr($zipEntry,strrpos($zipEntry,&#8221;/&#8221;)+1);
	$dirFile = $zipEntryFile;//unzipped directory
	$dirPath = $dir.&#8221;/&#8221;.$dirFile;
	$fp = [...]]]></description>
			<content:encoded><![CDATA[<p>ini_set(&#8217;memory_limit&#8217;,'800M&#8217;);<br />
set_time_limit(36000);<br />
/**<br />
*	@Module to Extract folder in one directory<br />
*	@package general<br />
*	@copyright Copyright 2010-11 COG IT Solutions Development Team<br />
*	@Author: Mr. Manoj M.Ninave<br />
**/<br />
//create media/import directory in root dir<br />
$dir = $_SERVER['DOCUMENT_ROOT'].&#8221;/media/import&#8221;;<br />
$filename = $dir.&#8221;/ABC.zip&#8221;;//destination<br />
$zip_file = &#8220;http://www.yourssite.com/ABC.zip&#8221;;//source</p>
<p>$contents = file_get_contents($zip_file);<br />
//echo $contents;<br />
$handle = fopen($filename, &#8220;w+&#8221;);<br />
fwrite($handle,$contents);<br />
fclose($handle);<br />
$zip = zip_open($filename);<br />
if ($zip)<br />
{<br />
  while ($zip_entry = zip_read($zip))<br />
  {<br />
	$zipEntry = zip_entry_name($zip_entry);<br />
	$zipEntryFile = substr($zipEntry,strrpos($zipEntry,&#8221;/&#8221;)+1);<br />
	$dirFile = $zipEntryFile;//unzipped directory<br />
	$dirPath = $dir.&#8221;/&#8221;.$dirFile;<br />
	$fp = fopen($dirPath, &#8220;w+&#8221;);<br />
	if (!$fp)<br />
		continue;<br />
    if(zip_entry_open($zip,$zip_entry, &#8220;r&#8221;))<br />
	{<br />
      $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));<br />
      fwrite($fp,$buf);<br />
      zip_entry_close($zip_entry);<br />
      fclose($fp);<br />
    }<br />
  }<br />
  zip_close($zip);<br />
}<br />
unlink($filename);<br />
//unlink($dirPath);<br />
echo &#8220;Unzipped successfully.&#8221;;</p>
<p>First it will copy zip file from source to destination.<br />
All the files in subdirectory will extract in one directory i.e. in media/import directory.</p>
<p>Regard</p>
<p>Manoj Ninave</p>
<p>Software Engineer,<br />
COG IT Solutions Pvt. Ltd.<br />
www.cogitsolutions.com<br />
n.manoj@cogitsolutions.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2010/02/how-to-unzipextract-zip-file-into-one-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento Tables required to Import Products.</title>
		<link>http://www.cogitsolutions.com/blog/2009/12/magento-tables-required-to-import-products/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/12/magento-tables-required-to-import-products/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 07:25:33 +0000</pubDate>
		<dc:creator>Manoj Ninave</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Development - PHP]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/2009/12/magento-tables-required-to-import-products/</guid>
		<description><![CDATA[Data inserted in following tables while importing products.
1)adminnotification_inbox
2)catalogindex_eav
3)catalogindex_price
4)cataloginventory_stock_item
5)cataloginventory_stock_status
6)catalogsearch_fulltext
7)catalog_category_product
8)catalog_category_product_index
9)catalog_product_enabled_index
10)catalog_product_entity
11)catalog_product_entity_datetime
12)catalog_product_entity_decimal
13)catalog_product_entity_int
14)catalog_product_entity_media_gallery
15)catalog_product_entity_media_gallery_value
16)catalog_product_entity_text
17)catalog_product_entity_varchar
18)catalog_product_link
19)catalog_product_link_attribute_int
20)catalog_product_website
21)core_url_rewrite
Regard
Manoj Ninave
Software Engineer,
COG IT Solutions Pvt. Ltd.
www.cogitsolutions.com
n.manoj@cogitsolutions.com
]]></description>
			<content:encoded><![CDATA[<p>Data inserted in following tables while importing products.</p>
<p>1)adminnotification_inbox<br />
2)catalogindex_eav<br />
3)catalogindex_price<br />
4)cataloginventory_stock_item<br />
5)cataloginventory_stock_status<br />
6)catalogsearch_fulltext<br />
7)catalog_category_product<br />
8)catalog_category_product_index<br />
9)catalog_product_enabled_index<br />
10)catalog_product_entity<br />
11)catalog_product_entity_datetime<br />
12)catalog_product_entity_decimal<br />
13)catalog_product_entity_int<br />
14)catalog_product_entity_media_gallery<br />
15)catalog_product_entity_media_gallery_value<br />
16)catalog_product_entity_text<br />
17)catalog_product_entity_varchar<br />
18)catalog_product_link<br />
19)catalog_product_link_attribute_int<br />
20)catalog_product_website<br />
21)core_url_rewrite</p>
<p>Regard</p>
<p>Manoj Ninave</p>
<p>Software Engineer,<br />
COG IT Solutions Pvt. Ltd.<br />
www.cogitsolutions.com<br />
n.manoj@cogitsolutions.com</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/12/magento-tables-required-to-import-products/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento &#8211; Cross-sells not showing in cart</title>
		<link>http://www.cogitsolutions.com/blog/2009/11/magento-cross-sells-not-showing-in-cart/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/11/magento-cross-sells-not-showing-in-cart/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 07:07:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Development - PHP]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/2009/11/magento-cross-sells-not-showing-in-cart/</guid>
		<description><![CDATA[if you are not managing stock, cross-sells will not show.
edit the cross-sell products that are not showing up. Go to the inventory tab on the edit product page and change these options:
Manage Stock: Yes
&#8211; Qty: > 0
—In Stock: Yes
you may want to change following setting also but not suggested if you want to manage stock [...]]]></description>
			<content:encoded><![CDATA[<p>if you are not managing stock, cross-sells will not show.</p>
<p>edit the cross-sell products that are not showing up. Go to the inventory tab on the edit product page and change these options:</p>
<p>Manage Stock: Yes<br />
&#8211; Qty: > 0<br />
—In Stock: Yes</p>
<p>you may want to change following setting also but not suggested if you want to manage stock on sale</p>
<p>in System > Configuration > Inventory </p>
<p>Decrease Stock When Order is Placed: No </p>
<p>Above settings will stop showing product in cross sell on check out when in stock status changes to out stock for cross sell product.<br />
If you want to show product in cross sell even if it is out of stock without changing above settings you need to make a small change in coding as below</p>
<p>go to app\code\core\Mage\Checkout\Block\Cart and open Crosssell.php<br />
search for Mage::getSingleton(&#8217;cataloginventory/stock&#8217;)->addInStockFilterToCollection($collection);<br />
comment this line</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/11/magento-cross-sells-not-showing-in-cart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delete multiple table in single query</title>
		<link>http://www.cogitsolutions.com/blog/2009/10/delete-multiple-table-in-single-query/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/10/delete-multiple-table-in-single-query/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:46:37 +0000</pubDate>
		<dc:creator>m.ganesh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/?p=52</guid>
		<description><![CDATA[Delete orders ,orders_products from orders INNER JOIN orders_products where orders.orders_id = orders_products.orders_id and orders.orders_id =24
m.ganesh@cogitsolutions.com
M/S COG IT SOLUTIONS
]]></description>
			<content:encoded><![CDATA[<p>Delete orders ,orders_products from orders INNER JOIN orders_products where orders.orders_id = orders_products.orders_id and orders.orders_id =24</p>
<p>m.ganesh@cogitsolutions.com<br />
M/S COG IT SOLUTIONS</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/10/delete-multiple-table-in-single-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>update with replace</title>
		<link>http://www.cogitsolutions.com/blog/2009/10/update-with-replace/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/10/update-with-replace/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:42:48 +0000</pubDate>
		<dc:creator>m.ganesh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/?p=50</guid>
		<description><![CDATA[update with replace
UPDATE wp_posts SET post_body = REPLACE(post_body, &#8216;needle&#8217;, &#8216;chocolate&#8217;);
m.ganesh@cogitsolutions.com
M/S COG IT SOLUTIONS
]]></description>
			<content:encoded><![CDATA[<p>update with replace<br />
UPDATE wp_posts SET post_body = REPLACE(post_body, &#8216;needle&#8217;, &#8216;chocolate&#8217;);</p>
<p>m.ganesh@cogitsolutions.com<br />
M/S COG IT SOLUTIONS</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/10/update-with-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check record an insert with in one query</title>
		<link>http://www.cogitsolutions.com/blog/2009/10/check-record-in-insert-with-in-one-query/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/10/check-record-in-insert-with-in-one-query/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:40:24 +0000</pubDate>
		<dc:creator>m.ganesh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/?p=47</guid>
		<description><![CDATA[Check record and insert with in one query
insert int tbl (Col1,col2,col3) select col1,col2,col3 from tbl where col1=&#8221;val&#8221;
]]></description>
			<content:encoded><![CDATA[<p>Check record and insert with in one query<br />
insert int tbl (Col1,col2,col3) select col1,col2,col3 from tbl where col1=&#8221;val&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/10/check-record-in-insert-with-in-one-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LI tag &#8211; list item</title>
		<link>http://www.cogitsolutions.com/blog/2009/10/li-tag-list-item/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/10/li-tag-list-item/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:37:11 +0000</pubDate>
		<dc:creator>m.ganesh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/?p=43</guid>
		<description><![CDATA[LI tag &#8211; list item
Used within the
 or
 tags to create the actual items of the list. Every list item should use the endtag 
 but many WYSIWYG web page editors omit the tag which can cause problems validating the resulting HTML file. The
 tag attributes are now deprecated in HTML4. Use CSS list-style-image and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>LI tag &#8211; list item</strong></p>
<p>Used within the</p>
<ul> or</p>
<ol> tags to create the actual items of the list. Every list item should use the endtag </li>
<p> but many WYSIWYG web page editors omit the tag which can cause problems validating the resulting HTML file. The</p>
<li> tag attributes are now deprecated in HTML4. Use CSS list-style-image and list-style-type properties of the
<li> tag.</p>
<p>    * li style = &#8220;list-style-type:none&#8221;<br />
    * li style = &#8220;list-style-type:disc&#8221;<br />
    * li style = &#8220;list-style-type:circle&#8221;<br />
    * li style = &#8220;list-style-type:square&#8221;<br />
    * li style = &#8220;list-style-type:decimal&#8221;<br />
    * li style = &#8220;list-style-type:upper-roman&#8221;<br />
    * li style = &#8220;list-style-type:lower-roman&#8221;<br />
    * li style = &#8220;list-style-type:upper-alpha&#8221;<br />
    * li style = &#8220;list-style-type:lower-alpha&#8221;<br />
    * li style = &#8220;list-style-image:url(../images/spot.png);&#8221;<br />
    * li style = &#8220;list-style-position:inside;&#8221;<br />
    * li style = &#8220;list-style-position:outside;&#8221;</p>
<p>&#8220;used style such as followes .Section1 ul<br />
{<br />
 padding:3px;</p>
<p>}<br />
.Section1 ul>li<br />
{<br />
 padding:2px 5px 2px;<br />
 font-weight:normal;<br />
 list-style-image:url(&#8221;"images/icon_bullet.gif&#8221;");<br />
 list-style-position:inside;<br />
}&#8221;</p>
<p>m.ganesh@cogitsolutions.com<br />
M/S COG IT SOLUTIONS</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/10/li-tag-list-item/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL_CALC_FOUND_ROWS or two queries</title>
		<link>http://www.cogitsolutions.com/blog/2009/10/sql_calc_found_rows-or-two-queries/</link>
		<comments>http://www.cogitsolutions.com/blog/2009/10/sql_calc_found_rows-or-two-queries/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 14:42:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.cogitsolutions.com/blog/2009/10/sql_calc_found_rows-or-two-queries/</guid>
		<description><![CDATA[While reading few posts I found that SQL_CALC_FOUND_ROWS is faster than two queries. But a very good discussion found at http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/comment-page-1/#comment-661064. check this out
One member posted following on above blog which is worth to read
Please visit the mysql official documentation here http://dev.mysql.com/doc/refman/5.1/en/information-functions.html
Please have a look at FOUND_ROWS() function. They have mentioned that it is much [...]]]></description>
			<content:encoded><![CDATA[<p>While reading few posts I found that SQL_CALC_FOUND_ROWS is faster than two queries. But a very good discussion found at http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/comment-page-1/#comment-661064. check this out</p>
<p>One member posted following on above blog which is worth to read</p>
<p>Please visit the mysql official documentation here http://dev.mysql.com/doc/refman/5.1/en/information-functions.html</p>
<p>Please have a look at FOUND_ROWS() function. They have mentioned that it is much faster to use the query with sql_calc_found_rows rather than using a query again. And I don’t find any reason not to trust them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cogitsolutions.com/blog/2009/10/sql_calc_found_rows-or-two-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
