Object Oriented Concepts

Class: This is a programmer-defined datatype, which includes local functions as well as local data. You can think of a class as a template for making many instances of the same kind (or class) of object.

Object: An individual instance of the data structure defined by a class. You define a class once and then make many objects that belong to it. Objects are also known as instance.

Member Variable: These are the variables defined inside a class. This data will be invisible to the outside of the class and can be accessed via member functions. These variables are called attribute of the object once an object is created.

Member function: These are the function defined inside a class and are used to access object data.

Inheritance: When a class is defined by inheriting existing function of a parent class then it is called inheritance. Here child class will inherit all or few member functions and variables of a parent class.

Parent class: A class that is inherited from by another class. This is also called a base class or super class.

Child Class: A class that inherits from another class. This is also called a subclass or derived class.

Polymorphism: This is an object oriented concept where same function can be used for different purposes. For example function name will remain same but it make take different number of arguments and can do different task.

Overloading: a type of polymorphism in which some or all of operators have different implementations depending on the types of their arguments. Similarly functions can also be overloaded with different implementation.

Data Abstraction: Any representation of data in which the implementation details are hidden (abstracted).

Encapsulation: refers to a concept where we encapsulate all the data and member functions together to form an object.

Constructor: refers to a special type of function which will be called automatically whenever there is an object formation from a class.

Destructors: refers to a special type of function which will be called automatically whenever an object is deleted or goes out of scope.

nginx

nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server, originally written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, nginx served or proxied 21.64% busiest sites in May 2015.

Nginx (pronounced engine-x) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Igor Sysoev started development of Nginx in 2002, with the first public release in 2004. Nginx now hosts nearly 12.18% (22.2M) of active sites across all domains. Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

Nginx is one of a handful of servers written to address the C10K problem. Unlike traditional servers, Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.
Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from Nginx’s high-performance and small memory footprint. Nginx scales in all directions: from the smallest VPS all the way up to clusters of servers.

Cannot redeem reward points with new theme Magento

1) Make sure that that the new theme has the following file .

layout/reward.xml
template/reward

2) If not there please copy the same from enterprise/layout/reward.xml enterprise/template/reward

3) Include the following in checkout.xml file

<block type=”core/template” name=”checkout.onepage.payment.additional” as=”additional” />
<block type=”core/template” name=”checkout.onepage.payment.methods_additional” as=”methods_additional” />

It should be placed within the payment block

<block type=”checkout/onepage_payment” name=”checkout.onepage.payment” as=”payment” template=”checkout/onepage/payment.phtml”>
<block type=”checkout/onepage_payment_methods” name=”checkout.payment.methods” as=”methods” template=”checkout/onepage/payment/info.phtml”>
<action method=”setMethodFormTemplate”><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
</block>
<block type=”core/template” name=”checkout.onepage.payment.additional” as=”additional” />
<block type=”core/template” name=”checkout.onepage.payment.methods_additional” as=”methods_additional” />
</block>

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();
}
}

}
?>

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;
}
}
?>