Wednesday, 4 March 2015

magento Call to a member function setProductFilter() on a non-object

It is a Major Problem in Magento 1.9.xx
I found the cause.

If your Problem  is - magento Call to a member function setProductFilter() on a non-object in app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php on line 294


Go to -
app/code/core/Mage/Catalog/Model/Resource/Product/Type/Configurable/Attribute/

And see there are the Collection.php file exist or not.
I thing there are Collection.php file exist but the file extension is not correct format.

You can change the extension only, Make it Collection.php


Thanks

Wednesday, 17 December 2014

Show product discount percent in Magento

Open app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml


Find

<?php endif; /* if ($_finalPrice == $_price): */ ?>


Add above it:

<?php // Discount percents output start ?>
    <?php if($_finalPrice < $_price): ?>
    <?php $_savePercent = 100 - round(($_finalPrice / $_price)*100); ?>
        <p class="special-price yousave">
            <span class="label"><?php echo $this->__('You Save:') ?></span>
            <span class="price">
                <?php echo $_savePercent; ?>%
            </span>
        </p>
    <?php endif; ?>
<?php // Discount percent output end ?>

Friday, 28 November 2014

magento set shipping estimate on cart page and get the shipping rates

<?php
$zipcode = '2000'; // Your zipcode
$country = 'GB'; // Your country Id
$cart = Mage::getSingleton('checkout/cart');
$address = $cart->getQuote()->getShippingAddress();
$address->setCountryId($country)->setPostcode($zipcode)->setCollectShippingrates(true);
$cart->save();

$rates = $address->collectShippingRates() ->getGroupedAllShippingRates();
if($rates) {
?>
<form id="co-shipping-method-form" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>" >
<?php
foreach ($rates as $carrier) {
    foreach ($carrier as $rate) {
//echo '<pre>';   print_r($rate->getData()); echo '</pre>';
if($rate->getCode() == "express_express") {  // Only show your custom shipping module
?>
<input name="estimate_method" type="checkbox" value="<?php echo $rate->getCode(); ?>" id="s_method_express_express" onclick="getShipppingCost();"  <?php if($rate->getCode()===$address->getShippingMethod()) echo ' checked="checked"' ?> class="radio">
             <label for="s_method_express_express"><?php echo $this->escapeHtml($rate->getMethodTitle()) ?>
<span class="price"> <?php echo  Mage::helper('core')->currency($rate->getPrice()); ?></span>
</label>
<?php  
}
    }
}

?>
<script>
function getShipppingCost()
{
var methodid= document.getElementById("s_method_express_express");
if(methodid.checked == true)
{ document.getElementById('co-shipping-method-form').submit(); }
else { methodid.value="freeshipping_freeshipping"; methodid.checked = true; document.getElementById('co-shipping-method-form').submit(); }

}

</script>

</form>
<?php } ?>

Thursday, 30 October 2014

magento set all image to thumbnail image

UPDATE catalog_product_entity_media_gallery AS mg,
       catalog_product_entity_media_gallery_value AS mgv,
       catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE  mg.value_id = mgv.value_id
AND mg.entity_id = ev.entity_id
AND ev.attribute_id IN (85,86,87)
AND mgv.position = 1;

Friday, 24 October 2014

php create word document from html

<html
    xmlns:o='urn:schemas-microsoft-com:office:office'
    xmlns:w='urn:schemas-microsoft-com:office:word'
    xmlns='http://www.w3.org/TR/REC-html40'>
    <head>
        <title>My Word Document</title>
       
    <xml>
        <w:WordDocument>
            <w:View>Print</w:View>
            <w:Zoom>100</w:Zoom>
            <w:DoNotOptimizeForBrowser/>
        </w:WordDocument>
    </xml>
 
    <style>
        p.MsoFooter, li.MsoFooter, div.MsoFooter{
            margin: 0cm;
            margin-bottom: 0001pt;
            mso-pagination:widow-orphan;
            font-size: 12.0 pt;
            text-align: right;
        }


        @page Section1{
            size: 29.7cm 21cm;
            margin: 2cm 2cm 2cm 2cm;
            mso-page-orientation: landscape;
            mso-footer:f1;
        }
        div.Section1 { page:Section1;}
    </style>
</head>
<body>
    <div class="Section1">
        <h1>Hello World! This My First</h1>
 
    </div>
</body>
</html>
<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=myfirst.doc");
?>

Friday, 10 October 2014

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::joinUrlRewrite() in app/code/local/Mage/Catalog/Block/Navigation.php on line 213

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat_Collection::joinUrlRewrite() in app/code/local/Mage/Catalog/Block/Navigation.php on line 213



This error is coming after upgrade magento to 1.9 CE.



 public function getCurrentChildCategories($sort_by = 'position', $sort_order = 'asc')

    {

        $layer = Mage::getSingleton('catalog/layer');

        $category   = $layer->getCurrentCategory();

        $collection = Mage::getModel('catalog/category')->getCollection();

        $collection->addAttributeToSelect('url_key')

            ->addAttributeToSelect('name')

            ->addAttributeToSelect('image')

            ->addAttributeToSelect('is_anchor')

            ->addAttributeToFilter('is_active', 1)

            ->addAttributeToSort($sort_by, $sort_order)

            ->addIdFilter($category->getChildren())

            ->joinUrlRewrite()

            ->load();



        $productCollection = Mage::getResourceModel('catalog/product_collection');

        $layer->prepareProductCollection($productCollection);

        $productCollection->addCountToCategories($collection);

        return $collection;

    }




change "->joinUrlRewrite()" to "->addUrlRewriteToResult()".

Then it will work fine!!!!!!!!!!!!!!

Thursday, 9 October 2014

Magento Call to a member function toHtml()

magento Call to a member function toHtml() on a non-object in app/code/core/Mage/Core/Model/Layout.php on line 555


Navigate to

\app\design\frontend\default\themename\layout\page.xml


Find
<block type="core/profiler" output="toHtml"/>
Replace with
<block type="core/profiler" output="toHtml" name="core_profiler"/>


Then refresh magento cache, and enjoy!!!!!!!!!!!!