2014/04/26

Support multi site for the magneto facebook login

A very common magento facebook login extension:

Belvg_FacebookFree
http://www.magentocommerce.com/magento-connect/facebook-connect-and-like-free.html?

 However it is not supporting multi site, so i did some changes to extension its function. The check existing fb id function only check the fb id if it is unique, without the current store id "where" clause


(1) Add a store_id column to database table 'belvg_facebook_customer' 

(2) Add the check existence function in 
/app/code/community/Belvg/FacebookFree/controllers/CustomerController.php in around line 52

$sql = 'SELECT `customer_id` FROM `' . $tablePrefix .
 'belvg_facebook_customer` WHERE `fb_id` = ' . $me['id'] .
 ' AND `store_id` = '.$store_id.' LIMIT 1';

Add AND `store_id` = '.$store_id.' 


(3) Insert the customer id/fb id pair with store id At around line 71, 
 $store_id = Mage::app()->getStore()->getStoreId(); // a new variable to save the current store_id

$sql = 'INSERT INTO `' . $tablePrefix . 'belvg_facebook_customer` VALUES (' . $r['entity_id'] . ', ' . $me['id'] .', '.$store_id. ')';

 Add one more column, the store id should be included in the insert clause. 


(4) Finished!
then the same fb_id can related to differrent magneto customer Id in different store

沒有留言:

發佈留言