Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Installation script for tvoe rating custom
- */
- $installer = $this;
- $installer->startSetup();
- function addOptions($rating) {
- for ($i = 1; $i <= 5; $i++) {
- Mage::getModel('rating/rating_option')->setData(
- array(
- 'rating_id' =>$rating->getId(),
- 'code' => $i,
- 'value' => $i,
- 'position' => $i
- )
- )->save();
- }
- }
- $ratingTvoe = array(
- 'rating_code' => 'tvoe_summary',
- 'entity_id' => 1,
- 'stores' => array(Mage::app()->getStore()->getId()),
- 'position' => 0
- );
- // Create rating
- $rating = Mage::getModel('rating/rating')->getCollection()->addFieldToFilter('rating_code', 'tvoe')->getFirstItem();
- if ($rating->getId()) {
- $rating->setRatingCode($ratingTvoe['rating_code']);
- $rating->setEntityId($ratingTvoe['entity_id']);
- $rating->setStores($ratingTvoe['stores']);
- $rating->setPosition(0);
- if (!count($rating->getOptions())) {
- addOptions($rating);
- }
- } else {
- $rating = Mage::getModel('rating/rating')->setData($ratingTvoe)->save();
- if (!count($rating->getOptions())) {
- addOptions($rating);
- }
- }
- $installer->endSetup();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement