magento change shipping and handling text

Copy the core file from this location..
app/code/core/Mage/Sales/Model/Quote/Address/Total/Shipping.php

and put this file to your local code pool..

app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php

Search this function "public function fetch" on the file and replace this text.
$title = Mage::helper('sales')->__('Shipping & handling'); // Original
$title = Mage::helper('sales')->__('Shipping'); // Replace

Fastest way to update magento products

When we Sync our Magento product Inventory and stock any third party API, we need to update whole product through cron and we simply use below method to update the product Data. which is slow product update in magento.




// Slow because load all product attribute

$sku = 'PSKU';

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
if ($product) {
 $product->setPrice(10);
 $product->setName('PRODUCT TITLE');
 $product->setDescription('PRODUCT DESCRIPTION');
 $product->save();
}
 unset($product);

// Fastest way to update magento product By Attribute

             

$sku = 'PSKU';
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);            
  if ($product) {                    
                    
                
    $product->setPrice(10);
    $product->getResource()->saveAttribute($product, 'price'); 
                    
    /** set product Disable/Enable **/           
                 
    $product->setStatus(1); // 1 => enabled, 0 => disabled     
    $product->getResource()->saveAttribute($product, 'status');              
                
    /** set product Tax  **/                
             
    $product->setTaxClassId('2'); // 2 => Taxable Goods, 0 => None,  4 => Shipping   
    $product->getResource()->saveAttribute($product, 'tax_class_id');
                     
              
  }    
                   
 unset($product);  




Show Quantity and stock information on configurable product drop down

Output of this below code..
qty-instock-magento-product-attribute




outofstock-magento-product-attribute








Create a Gts_Oos.xml file in app/etc/modules/


<config>
    <modules>
        <Gts_Oos>
            <active>true</active>
            <codePool>local</codePool>
        </Gts_Oos>
    </modules>
</config>

Create a folder on app/code/local/Gts/Oos/
Create a folder on app/code/local/Gts/Oos/etc/

Create a config.xml file inside etc/config.xml folder
and put that below code on this file.



<?xml version="1.0"?>
<config>
    <modules>
        <Gts_Oos>
            <version>1.0</version>
        </Gts_Oos>
    </modules>
               
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <product_view_type_configurable>Gts_Oos_Block_Configurable</product_view_type_configurable>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

Create a folder on app/code/local/Gts/Oos/Block/



Create a Configurable.php file inside Block/Configurable.php folder
and put that below code on this file.


<?php
 
class Gts_Oos_Block_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable
{   
	public function getAllowProducts()
	{
		if (!$this->hasAllowProducts()) {
						$products = array();
						$allProducts = $this->getProduct()->getTypeInstance(true)
										->getUsedProducts(null, $this->getProduct());
						$this->setAllowProducts($allProducts);
		}
		return $this->getData('allow_products');
		
	}
		
	/**
	 * Composes configuration for js
	 *
	 * @return string
	 */
    public function getJsonConfig()
    {
 		$attributes = array();
        $options    = array();
        $store      = $this->getCurrentStore();
        $taxHelper  = Mage::helper('tax');
        $currentProduct = $this->getProduct();
 
        $preconfiguredFlag = $currentProduct->hasPreconfiguredValues();
        if ($preconfiguredFlag) {
            $preconfiguredValues = $currentProduct->getPreconfiguredValues();
            $defaultValues       = array();
        }
 
        foreach ($this->getAllowProducts() as $product) {
            $productId  = $product->getId();
			
			foreach ($this->getAllowAttributes() as $attribute) {
				$productAttribute = $attribute->getProductAttribute();
				$attributeValue = $product->getData($productAttribute->getAttributeCode());
				
				$options['qty'][$product -> getAttributeText($productAttribute->getName())] = floor($product->getStockItem()->getQty());
				
				if (!isset($options[$productAttribute->getId()])) {
				$options[$productAttribute->getId()] = array();
				}
			   
				if (!isset($options[$productAttribute->getId()][$attributeValue])) {
				$options[$productAttribute->getId()][$attributeValue] = array();
				}
				$options[$productAttribute->getId()][$attributeValue][] = $productId;
				}
        }
 
        $this->_resPrices = array(
            $this->_preparePrice($currentProduct->getFinalPrice())
        );
 
        foreach ($this->getAllowAttributes() as $attribute) {
            $productAttribute = $attribute->getProductAttribute();
            $attributeId = $productAttribute->getId();
            $info = array(
               'id'        => $productAttribute->getId(),
               'code'      => $productAttribute->getAttributeCode(),
               'label'     => $attribute->getLabel(),
               'options'   => array()
            );
 
            $optionPrices = array();
            $prices = $attribute->getPrices();
            if (is_array($prices)) {
                foreach ($prices as $value) {
                    if(!$this->_validateAttributeValue($attributeId, $value, $options)) {
                        continue;
                    }
                    $currentProduct->setConfigurablePrice($this->_preparePrice($value['pricing_value'], $value['is_percent']));
                    Mage::dispatchEvent(
                        'catalog_product_type_configurable_price',
                        array('product' => $currentProduct)
                    );
                    $configurablePrice = $currentProduct->getConfigurablePrice();
                    $qty='';
                    $qty = $options['qty'][$value['label']];
					$info['options'][] = array(
					'id' => $value['value_index'],
					'label' => ($options['qty'][$value['label']] <= 0) ? $value['label'] . ' (Out Of Stock)' : $value['label']. '('.$qty.') In Stock',
					'price' => $configurablePrice,
					'oldPrice'  => $this->_preparePrice($value['pricing_value'], $value['is_percent']),
					'products' => isset($options[$attributeId][$value['value_index']]) ? $options[$attributeId][$value['value_index']] : array(),);                                                                               
                    $optionPrices[] = $configurablePrice;
									
					
                }
            }
            /**
             * Prepare formated values for options choose
             */
            foreach ($optionPrices as $optionPrice) {
                foreach ($optionPrices as $additional) {
                    $this->_preparePrice(abs($additional-$optionPrice));
                }
            }
            if($this->_validateAttributeInfo($info)) {
               $attributes[$attributeId] = $info;
            }
 
            // Add attribute default value (if set)
            if ($preconfiguredFlag) {
                $configValue = $preconfiguredValues->getData('super_attribute/' . $attributeId);
                if ($configValue) {
                    $defaultValues[$attributeId] = $configValue;
                }
            }
        }
 
        $taxCalculation = Mage::getSingleton('tax/calculation');
        if (!$taxCalculation->getCustomer() && Mage::registry('current_customer')) {
            $taxCalculation->setCustomer(Mage::registry('current_customer'));
        }
 
        $_request = $taxCalculation->getRateRequest(false, false, false);
        $_request->setProductClassId($currentProduct->getTaxClassId());
        $defaultTax = $taxCalculation->getRate($_request);
 
        $_request = $taxCalculation->getRateRequest();
        $_request->setProductClassId($currentProduct->getTaxClassId());
        $currentTax = $taxCalculation->getRate($_request);
 
        $taxConfig = array(
            'includeTax'        => $taxHelper->priceIncludesTax(),
            'showIncludeTax'    => $taxHelper->displayPriceIncludingTax(),
            'showBothPrices'    => $taxHelper->displayBothPrices(),
            'defaultTax'        => $defaultTax,
            'currentTax'        => $currentTax,
            'inclTaxTitle'      => Mage::helper('catalog')->__('Incl. Tax')
        );
 
        $config = array(
            'attributes'        => $attributes,
            'template'          => str_replace('%s', '#{price}', $store->getCurrentCurrency()->getOutputFormat()),
//            'prices'          => $this->_prices,
            'basePrice'         => $this->_registerJsPrice($this->_convertPrice($currentProduct->getFinalPrice())),
            'oldPrice'          => $this->_registerJsPrice($this->_convertPrice($currentProduct->getPrice())),
            'productId'         => $currentProduct->getId(),
            'chooseText'        => Mage::helper('catalog')->__('Choose an Option...'),
            'taxConfig'         => $taxConfig
        );
 
        if ($preconfiguredFlag && !empty($defaultValues)) {
            $config['defaultValues'] = $defaultValues;
        }
 
        $config = array_merge($config, $this->_getAdditionalConfig());
 
        return Mage::helper('core')->jsonEncode($config);
    }
	
}
?>

Please clear your magento cache through Admin.

How to get product stock quantity and stock information in magento

Magento product model(Object) does not pull the product stock, Quantity and other information
related to product stock. We need to pull this information using cataloginventory model.

Get product quantity and stock by Product ID


$_product = Mage::getModel('catalog/product')->load($products_id); 

$stockInfo = (int)Mage::getModel('cataloginventory/stock_item')
                ->loadByProduct($_product);

echo '<pre>';
print_r($stockInfo->getData());
echo '</pre>';

// For Quantity
echo $stockInfo->getQty();
Similar you can find all product stock information like.. 

// For Minimum Sale Quantity
echo $stockInfo->getMinSaleQty();

// For Maximum Sale Quantity
echo $stockInfo->getMaxSaleQty();

// For Maximum Sale Quantity
echo $stockInfo->getIsInStock();

//Get product quantity and stock data by product Object

$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product); 
$product is a product object
echo '<pre>';
print_r($stockItem->getData());
echo '</pre>';