Magento控制器和模型内部服务器错误

时间:2016-02-27 10:24:08

标签: magento

以下是我的js代码:

$("#personalize_design_button").click(function(){
    category_type = $(".cc-selector input[name='category']:checked").val();
    shape_type = $(".shape-selector input[name='shape']:checked").val();

    $.ajax({
     url: "/index.php/designs/designs/product/ctype/"+category_type+"/stype/"+shape_type,
     type: "GET",
     dataType: "json",
     success: function(data) 
            {
              alert(data);
            },
        error: function(error)
              {
                 console.log("Error:");
                 console.log(error);

              }
    });

    //$(".col-md-9").append('<div class="col-xs-18 col-sm-3 col-md-3"><div class="productbox"><div class="imgthumb img-responsive"><img src="http://lorempixel.com/250/250/business/?ab=1df"></div><div class="caption"><span style="float:left;">Modern Trendy Bedroom</span><span class="pull-right">Rs.129000</span><div class="caption"><span style="float:left;">Tag1</span><span style="float:left;">Tag2</span><span>Tag3</span></div><div class="caption"><span style="float:left;">Tag4</span><span style="float:left;">Tag5</span><span>Tag6</span></div></div></div></div>');
    //$(".col-md-9").load('product_category.phtml');
});

我的Magento控制器类:

public function productAction()
{
    $category_type = $this->getRequest()->getParam('ctype');
    $shape_type = $this->getRequest()->getParam('stype');

    ChromePhp::log('ctype-----'.$category_type.'------'.$shape_type);
    //$category_type = $_GET['ctype'];
    //$shape_type = $_GET['stype'];
    $products = Mage::getModel("designs/designs")->getRecentProducts($category_type,$shape_type);
    return json_encode($products);
}

和我的模特课:

    <?php

 include 'http://52.25.99.121/ChromePhp.php';
class Homeliv_Designs_Model_Designs extends Mage_Core_Model_Abstract
{

    const BEDROOM = 11;

   public function getRecentProducts($category_type,$shape_type)
   {
       ChromePhp::log("inside model-----".$category_type);
       $ctype = 0;
       if($category_type == 1){
           $ctype = BEDROOM;
       }
       //ChromePhp::log("inside model-----".$category_type);
        $products = Mage::getSingleton('catalog/category')->load($ctype)
            ->getProductCollection()
            ->addAttributeToSelect('*')
            ->addAttributeToFilter('price', array( 'lt' => 300000 ));
            //->addAttributeToFilter('shapes', array( 'eq' => $shape_type ));
        ChromePhp::log('Total products-----'.count($products);
        foreach ($products as $_product){
            ChromePhp::log('inside model-----'.$_product->getId().'------'.$_product->getShape());
        }
       ChromePhp::log('inside model-------'.count($products));

        return $products;
  }
}

此代码记录控制器中的行,但不记录模型内的行。我想流程是控制器收到的ajax请求,然后调用模型类中的getRecentProducts()方法。但它以某种方式抛出500内部服务器错误。需要帮助来解决它。我在这里做错了什么?

0 个答案:

没有答案