Loops Magento问题?如何在表中循环添加评论
我试图通过流通增加评论的数据,有以下代码Loops Magento问题?如何在表中循环添加评论,loops,magento,foreach,add,review,Loops,Magento,Foreach,Add,Review,我试图通过流通增加评论的数据,有以下代码 $i=1; while($i<=2){ $review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE)) ->setEntityPkValue($product->getId()) ->setStatusId(Mage_Review_
$i=1;
while($i<=2){
$review->setEntityId($review->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
->setEntityPkValue($product->getId())
->setStatusId(Mage_Review_Model_Review::STATUS_APPROVED)
->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
->setStoreId(Mage::app()->getStore()->getId())
->setStores(array(Mage::app()->getStore()->getId()))
->save();
$i++;
}
结果只加入一个数据,没有我预期的两个数据
请求帮助!谢谢!我不知道为什么,但在方法/循环中不能两次使用$variable。
使用完整的Magento实例,例如:Mage::getModel'module/model'使用Mage::getModel'review/review'->getCollection;用于获取特定模块的所有模型数据的函数