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!!!!!!!!!!!!