开发者

Magento question? How to loop add reviews in the table?

I attempt through the circulation increase the commentary the data, has the following code

 $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)
          ->setCustome开发者_如何学编程rId(Mage::getSingleton('customer/session')->getCustomerId())
          ->setStoreId(Mage::app()->getStore()->getId())
          ->setStores(array(Mage::app()->getStore()->getId()))
          ->save();
      $i++;
    }

The result only joins a data, does not have my anticipated two data。 Request help! Thanks!


I don't know why, but you can't use $variable twice in a method/loop.
Use the full Magento instanciation instead, ie: Mage::getModel('module/model')


use Mage::getModel('review/review')->getCollection(); function for get all model data of particular module.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜