0

I am trying to make a custom module for product quick view. Their only need to load catalog/product/view.phtml

Here is My code

app\code\local\Abdus\Ajaxproduct\controllers\LoadproductController.php

<?php
class Abdus_Ajaxproduct_LoadproductController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){
        $this->loadLayout();
        $this->renderLayout();
    }
    public function getbyskuAction(){
        $_prdSku    = $this->getRequest()->getParam('sku');
        $_product   = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('sku',$_prdSku);
        $this->productInfo($_product);
    }
    public function getbyidAction(){
        $_prdID     = intval($this->getRequest()->getParam('id'));
        $_product   = Mage::getModel('catalog/product')->getCollection()->load($prdID);
        $this->productInfo($_product);
    }
    public function productInfo($_product){
        $this->loadLayout();
        $this->renderLayout();
    }
}

app\code\local\Abdus\Ajaxproduct\etc\config.xml

<config>
    <modules>
        <Abdus_Ajaxproduct>
            <version>1.0.0</version>
        </Abdus_Ajaxproduct>
    </modules>
    <frontend>
        <routers>
            <ajaxproduct>
                <use>standard</use>
                <args>
                    <module>Abdus_Ajaxproduct</module>
                    <frontName>ajaxproduct</frontName>
                </args>
            </ajaxproduct>
        </routers>
    </frontend>
</config>

app\design\frontend\base\default\layout\local.xml

<?xml version="1.0" encoding="utf-8"?>
<layout version="0.1.0">
    <ajaxproduct_loadproduct_getbysku>
        <remove name="head" />
        <remove name="header" />
        <remove name="footer" />
        <remove name="right" />
        <remove name="left" />
        <reference name="root">
            <block type="page/html" name="content" output="toHtml" template="catalog/product/view.phtml"/>
        </reference>
    </ajaxproduct_loadproduct_getbysku>
</layout>

But when i call my link

mysite/ajaxproduct/loadproduct/getbysku/sku/418

Then I get a error

Fatal error: Call to a member function getOptions() on null in D:\x\htdocs\m1\app\design\frontend\rwd\default\template\catalog\product\view.phtml on line 42

2

Incorrect block type.

Have a look at /frontend/base/default/layout/catalog.xml You'll have to use this block nesting: Take reference "content" instead of "root" and use correct block type.

 <reference name="content">
                <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

...
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.