<?php //$rule = Mage::getModel('salesrule/rule')->load(3); $rule = Mage::getModel('catalogrule/rule')->load(3); $rule->setWebsiteIds("1"); $currentDate = date('Y-m-d'); $startDate = $rule->getFromDate(); $endDate = $rule->getToDate(); $_category = Mage::registry('current_category'); $currentCategoryId= $_category->getId(); $PromoRule = unserialize($rule->getConditionsSerialized()); //echo '<pre>'; print_r($PromoRule['conditions']['0']['value']); die; //$PromoRuleCategory = explode(",",$PromoRule['conditions']['0']['value']); $PromoRuleCategory = ''; $totalSubCategoryIds = array(); $conditions = $rule->getConditions(); foreach($conditions['conditions'] as &$condition) { if($condition->getAttribute() == 'category_ids') { $categoryIds = explode(',', $condition->getValue()); if($categoryIds) { $categoryIds = array_map('trim', $categoryIds); if(count($categoryIds)) { foreach ($categoryIds as $categoryId) { $category = Mage::getModel('catalog/category')->load($categoryId); if ($category->getIsAnchor()) { $subCategoryIds = $category->getResource()->getChildren($category, true); $totalSubCategoryIds = array_merge($totalSubCategoryIds,$subCategoryIds); } } } } $PromoRuleCategory = array_merge($categoryIds, array_unique($totalSubCategoryIds)); } } if ((($currentDate >= $startDate) && ($currentDate <= $endDate)) && (in_array($currentCategoryId,$PromoRuleCategory))) { if($rule->getIsActive()) { if ((int)$rule->getDiscountAmount() == 20) { echo '<span class="sale-flag prozent20">'.$this->__('sale').'</span>'; } if ((int)$rule->getDiscountAmount() == 10) { echo '<span class="sale-flag prozent10">'.$this->__('sale').'</span>'; } } } ?>