Archive

Archive for the ‘Magento’ Category

Magento Override Controller

Here we are overing the function addAction in CartController.php

1) Chnage the directory to magento installtion

2) vi app/etc/modules/Phpcodez_Checkout.xml
<?xml version=”1.0″?>
<config>
<modules>
<Phpcodez_Checkout>
<active>true</active>
<codePool>local</codePool>
</Phpcodez_Checkout>
</modules>
</config>

3)vi app/code/local/Phpcodez/Checkout/etc/config.xml

<?xml version=”1.0″?>
<config>

<modules>
<Phpcodez_Checkout>
<version>0.1.0</version>
</Phpcodez_Checkout>
</modules>

<frontend>
<routers>
<checkout>
<args>
<modules>
<phpcodez_checkout before=”Mage_Checkout”>Phpcodez_Checkout</phpcodez_checkout>
</modules>
</args>
</checkout>
</routers>
</frontend>

</config>

3) vi app/code/local/Phpcodez/Checkout/controllers/CartController.php

<?php
require_once Mage::getModuleDir(‘controllers’, ‘Mage_Checkout’).DS.’CartController.php’;

class Phpcodez_Checkout_CartController extends Mage_Checkout_CartController{

public function addAction() {
$cart = $this->_getCart();
$params = $this->getRequest()->getParams();
try {
if (isset($params['qty'])) {
$filter = new Zend_Filter_LocalizedToNormalized(
array(‘locale’ => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);
}

$product = $this->_initProduct();
$related = $this->getRequest()->getParam(‘related_product’);

/**
* Check product availability
*/
if (!$product) {
$this->_goBack();
return;
}

$cart->addProduct($product, $params);
if (!empty($related)) {
$cart->addProductsByIds(explode(‘,’, $related));
}

$cart->save();

$this->_getSession()->setCartWasUpdated(true);

/**
* @todo remove wishlist observer processAddToCart
*/
Mage::dispatchEvent(‘checkout_cart_add_product_complete’,
array(‘product’ => $product, ‘request’ => $this->getRequest(), ‘response’ => $this->getResponse())
);

if (!$this->_getSession()->getNoCartRedirect(true)) {
if (!$cart->getQuote()->getHasError()){
$message = $this->__(‘%s was added to your shopping cart.’, Mage::helper(‘core’)->escapeHtml($product->getName()));
$this->_getSession()->addSuccess($message);
}
$this->_goBack();
}
} catch (Mage_Core_Exception $e) {
if ($this->_getSession()->getUseNotice(true)) {
$this->_getSession()->addNotice(Mage::helper(‘core’)->escapeHtml($e->getMessage()));
} else {
$messages = array_unique(explode(“\n”, $e->getMessage()));
foreach ($messages as $message) {
$this->_getSession()->addError(Mage::helper(‘core’)->escapeHtml($message));
}
}

$url = $this->_getSession()->getRedirectUrl(true);
if ($url) {
$this->getResponse()->setRedirect($url);
} else {
$this->_redirectReferer(Mage::helper(‘checkout/cart’)->getCartUrl());
}
} catch (Exception $e) {
$this->_getSession()->addException($e, $this->__(‘Cannot add the item to shopping cart.’));
Mage::logException($e);
$this->_goBack();
}
}

}
?>

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , , ,

Magento Override Block

1) Change the directory to magento installation

2) vi app/etc/modules/Phpcodez_Checkout.xml and paste the below given code
<?xml version=”1.0″?>
<config>
<modules>
<Phpcodez_Checkout>
<active>true</active>
<codePool>local</codePool>
</Phpcodez_Checkout>
</modules>
</config>
3) mkdir app/code/local/Phpcodez
4) mkdir app/code/local/Phpcodez/Checkout
5) mkdir app/code/local/Phpcodez/Checkout/etc
6) mkdir app/code/local/Phpcodez/Checkout/Block
7) vi app/code/local/Phpcodez/Checkout/etc/config.xml and paste the below given code
<?xml version=”1.0″?>
<config>
<modules>
<Phpcodez_Checkout>
<version>0.1.0</version>
</Phpcodez_Checkout>
</modules>
<global>
<blocks>
<checkout>
<rewrite>
<links>Phpcodez_Checkout_Block_Links</links>
</rewrite>
</checkout>
</blocks>
</global>
</config>

8) vi app/code/local/Phpcodez/Checkout/Block/Links.php and paste here the below given code
<?php
class Phpcodez_Checkout_Block_Links extends Mage_Checkout_Block_Links{
public function addCheckoutLink() {

if (!$this->helper(‘checkout’)->canOnepageCheckout()) {
return $this;
}

$parentBlock = $this->getParentBlock();
if ($parentBlock && Mage::helper(‘core’)->isModuleOutputEnabled(‘Mage_Checkout’)) {
$text = $this->__(‘Checkout Overriden’);
$parentBlock->addLink(
$text, ‘checkout’, $text,
true, array(‘_secure’ => true), 60, null,
‘class=”top-link-checkout”‘
);
}
return $this;
}
}
?>

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , , ,

Magento Logged in user details

Mage::getSingleton(‘customer/session’)->getCustomer()->getName()

Mage::getSingleton(‘customer/session’)->getCustomer()->getFirstname()

Mage::getSingleton(‘customer/session’)->getCustomer()->getLastname()

Mage::getSingleton(‘customer/session’)->getCustomer()->getEmail()

 

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , ,

How do I remove the “My Cart” and “Checkout” Toplinks?

1) Edit the page checkout.xml and search for the below text

<reference name=”top.links”>
<block type=”checkout/links” name=”checkout_cart_link”>
<action method=”addCartLink”></action>
<action method=”addCheckoutLink”></action>
</block>
</reference>

and comment the unwanted links .

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , ,

Assisted shopping cart mode Magento

1) If the admin doesn’t want the  display of reduced prices online, orders can be placed by using the assisted shopping cart mode.

2) In this mode admin can make order on behalf of users .its applicable only for logged in users

3) After adding the product , users should call the admin .

4) Admin searches for the customer record. (Customer – Manage customer- select customer) from admin side

4) Click on the ‘manage shopping cart’ button at the top.

6)Select the Products tab and choose products and Qty and click ‘Add Selected Products to Shopping Cart’ and Click on “Create Order” option

7) After filling the required details press on “Submit order”

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare

Modify the label special price Magento

1) Edit the attribute “special_price”
2) Click on the tab “Manage Label Opions”
3) Set the required label for “Default Store View”
4) Save the attribute

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , , ,

Check configurable product or not product detail page Magento

Add the below given code on catalog/product/view.phtml

<?php if($_product->getTypeId() == “configurable”) echo “Its a configurable product”; ?>

 

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , ,

Attribute value from product id magento

<?php echo Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId); ?>

 

EmailFacebookLinkedInMySpaceDiggTumblrStumbleUponShare
Categories: Magento Tags: , ,

Switch to our mobile site