Last active
April 14, 2016 08:43
-
-
Save kanampalli/692edcf70ca48d02a532f410ddf219be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$product = Mage::getModel('catalog/product')->load(87); // Random product ID | |
// get cart and add product | |
$cart = Mage::getSingleton('checkout/cart'); | |
$cart->init(); | |
$cart->addProduct($product, 2); | |
// update session | |
$session->setCartWasUpdated(true); | |
// save the cart | |
$cart->save(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Customer Login: | |
umask(0); | |
ob_start(); | |
session_start(); | |
Mage::app('default'); | |
$websiteId = Mage::app()->getWebsite()->getId(); | |
$store = Mage::app()->getStore(); | |
$customer = Mage::getModel("customer/customer"); | |
$customer->website_id = $websiteId; | |
$customer->setStore($store); | |
$customerEmail = "example@gmail.com"; | |
$customer = Mage::getModel('customer/customer')->setWebsiteId($websiteId)->loadByEmail($customerEmail); | |
try { | |
$customer->loadByEmail("example@gmail.com"); | |
$session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer); | |
$a = $session->login($customerEmail, "Magentodf3d"); | |
if(Mage::getSingleton('customer/session')->isLoggedIn()): | |
$customer = Mage::getSingleton('customer/session')->getCustomer()->getName(); | |
$customer = Mage::getSingleton('customer/session')->getCustomer(); | |
Mage::getSingleton("core/session", array("Name" => "frontend")); | |
$session=Mage::getSingleton('customer/session', array('Name'=>'frontend') ); | |
if ( $session->isLoggedIn() ) { | |
$session = Mage::getSingleton('customer/session')->setCustomerAsLoggedOut($customer); | |
// $session->logout(); | |
if ( $session->isLoggedIn() ) { | |
echo "secondlogged in"; | |
}else{ | |
echo "not secondlogged in"; | |
} | |
} else { | |
echo "not logged in"; | |
} | |
endif; | |
} | |
catch(Exception $e){ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$allStores = Mage::app()->getStores(); | |
foreach ($allStores as $_eachStoreId => $val) | |
{ | |
$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode(); | |
$_storeName = Mage::app()->getStore($_eachStoreId)->getName(); | |
$_storeId = Mage::app()->getStore($_eachStoreId)->getId(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$id = '87'; // replace product id with your id | |
$cartHelper = Mage::helper('checkout/cart'); | |
$items = $cartHelper->getCart()->getItems(); | |
foreach($items as $item): | |
if($item->getProduct()->getId() == $id): | |
$itemId = $item->getItemId(); | |
$cartHelper->getCart()->removeItem($itemId)->save(); | |
break; | |
endif; | |
endforeach; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mage::app('admin')->setCurrentStore(1); | |
// Mage::app()->setCurrentStore($store_id); | |
// Mage::run($mageRunCode, $mageRunType); | |
$store = Mage::getModel('core/store')->load(1); | |
echo $store->getCode(); | |
// $store = Mage::app()->getStore(); | |
// echo $store; | |
Mage::getSingleton('core/session', array('name'=>'frontend')); | |
$_product = Mage::getModel('catalog/product')->load(87); /*87 is Product ID | |
$_product->getPrice(); | |
echo $_product->getPrice(); | |
$_product->setPrice(400); | |
$_product->save(); | |
echo $_product->getPrice(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment