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



Tuesday, 30 September 2014

Fatal error: Call to a member function toOptionArray() on a non-object in app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 463

Go to app\code\core\Mage\Adminhtml\Block\System\Config\Form.php

find the following on line 463

$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
and replace it with the following:

if(is_object($sourceModel)){
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');

Magento Order of loading configure of modules

*Mage_All.xml will be loaded first, and it's module configure in this file will be loaded first
*Mage_*.xml
*.xml
And rest file.xml will be loaded according to the order of the rest file’s name.

Model-View-Controller (MVC)

=> Model
Model is the classes providing data, service related to data and business logic. This class works directly with data and provides data for other elements. In a module, these classes are contained in Model folder.
=> View
View is the classes which define data presented method. These classes are contained in the folder Block of module.
=> Controller
Controller is the classes which control application stream. They receive input which is requirement of users through HTTP request, transfer those requests to the classes which process the requests directly. From the link, Router will get to Controller which controls that link. In Magento module, these classes are contained in controller folder.








How to redirect non-WWW URL to WWW URL

Add the following code on .htaccess file

RewriteEngine On
RewriteCond %{HTTP_HOST}  ^debendramagentoblogspot.com/ [nocase]
RewriteRule ^(.*)         http://www.debendramagentoblogspot.com/$1 [last,redirect=301]

It above one code not worked then add the following code on .htaccess fole

RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]