I’ve already made a post in this blog about Adding Related Product and other links to Product in Magento . But when I used the method to creating links among product’s, while importing very large number of products and creating large number of product links, it took a lot of time and resource. So I thought why not give it a try by direclty creating a link using SQL? And YES! it worked.

 

Below is the code how I created those links using Custom SQL. But I have to tell you that the former methods looks organized, this is just a work around to a situation. You might know what I am trying to say!

?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$resource   = Mage :: getSingleton( 'core/resource' );
$read= $resource -> getConnection( 'core_read' );
$write= $resource->getConnection('core_write');
$linkTable=$resource->getTableName('catalog/product_link');
// Creating Upsell Product link
$write->query("INSERT into $linkTable SET
                            product_id='".$productId."',
                            linked_product_id='".$linkProduct."',
                            link_type_id='".Mage_Catalog_Model_Product_Link::LINK_TYPE_UPSELL."'
            ");
// Creating Related Product link
$write->query("INSERT into $linkTable SET
                            product_id='".$productId."',
                            linked_product_id='".$linkProduct."',
                            link_type_id='".Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED."'
            ");
// Creating Crosssell Product Link
$write->query("INSERT into $linkTable SET
                            product_id='".$productId."',
                            linked_product_id='".$linkProduct."',
                            link_type_id='".Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL."'
            ");

Tags: , , , , ,

Comments are closed.


Link Exchange Spritual Place for Bhakti | bhaktiguru.com Business Franchise in India | businessfranchiseindia.com Free Directory Submission & Link Submission | ab-directory.com Big Dwarka Business Listing | bigdwarka.com Kolkata Online Business Listing | onlinekolkata.com Patna Online Business Listing | onlinepatna.com Dwarka Online Business Listing | onlinedwarka.com Bihar Online | First Bihar's Portal | bihar-online.com Big Bihar Business Listing | bigbihar.com Dynamic Website Development | dynamicwebsitedeveloper.com Noida Online Business Listing | onlinenoida.com SEO Service Delhi & India | seoservicedelhi.com SEO Experts Delhi & India | seoexpertsdelhi.com Big Patna Business Listing | bigpatna.com Bihar schools Listing Free Schools Ad | biharschools.com Creative Websoft Solutions | Web Development India | creativewebsoft.us Bulk SMS Providers India | bulksmsproviders.net Online cbse Guides | onlinecbseguides.com Big Kolkata Business Listing | bigkolkata.com Handicap Shaadi.com | handicapshaadi.com Handicap Marriage.com | handicapmarriage.com India Home Tutors.com | indiahometutors.com Indian Property Guides.com | indianpropertyguides.com Online Stocks Community.com | onlinestockscommunity.com Free Article Submission | ab-articles.com Secret Dating Online.com | secretdatingonline.com Private DatingOnline.com | privatedatingonline.com Indian businessguides.com | indianbusinessguides.com Software Engineer Delhi | Meenu Khanna Bollywood & Hot Images | hibdy.com Free Computer & Online PHP Training | php2php.com Free Ignou Project & Assignment | ignouinfo.com PHP Programmer India | Web Developer India | bageshsingh.com Creative Websoft Solutions | Web Development IndiaBlog Link Exchange http://www.php2php.com/tutorial-blog/http://bageshsingh.com/bagesh-blog/http://www.bhaktiguru.com/bhaktigurublog/http://www.hibdy.com/desi-masala-blog/