作为我自己主题的一部分,我正在构建一个ajax购物车系统。当我尝试添加简单或可配置的产品时,会出现一个错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'website_ids' in 'where clause'
这是我的密码:
function add_to_cartAction($product = false)
{
$data = json_decode(base64_decode($_POST['data']) , true);
if(!$product)
{
$product = Mage::getModel('catalog/product')->load($data['entity_id']);
}
try{
if($product->getTypeId() == 'simple'){
$params = array(
'qty' => $data['quantity'] ,
'product' => $product->getId()
);
$this->addProduct($product , $params);
die(base64_encode(json_encode(array('success' => 'Successfully added product to cart'))));
}else{
$options = $data['attrs'];
$_matchedItem = null;
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
foreach($childProducts as $item)
{
$matchAmount = count($options);
$matched = 0;
foreach($options as $attr => $option)
{
if($item->getData($attr) == $option)
{
$matched++;
}
}
if($matched == $matchAmount)
{
$_matchedItem = $item;
break;
}
}
if($_matchedItem == null)
{
throw new Exception("Matched Item is null");
}
$params = array(
'qty' => $data['quantity'] ,
'product' => $_matchedItem->getId()
);
$this->addProduct($_matchedItem , $params);
die(base64_encode(json_encode(array('success' => 'Successfully added product to cart'))));
}
}catch(Exception $e)
{
die($e->getMessage());
}
}
function addProduct($product , $params)
{
$cart = Mage::getModel('checkout/cart');
$cart->init();
$cart->setWebsiteId(Mage::app()->getWebsite()->getId());
$cart->setStoreId(Mage::app()->getStore()->getId());
$cart->getQuote()->addProduct($product , $params['qty']);
$cart->getQuote()->save();
$cart->save();
}
每当我尝试将产品添加到购物车时,我都会遇到问题 salesrule
表,表示该列网站不存在,尽管在magento的工作版本上,它不存在,但仍然有效。我真的很困惑,有人能解决这个问题吗?
编辑*添加salesrule表的屏幕截图。
暂无答案!
目前还没有任何答案,快来回答吧!