/** * Preparing data and adding to rss object * * @param array $args */ public function addSpecialXmlCallback($args) { if (!isset(self::$_currentDate)) { self::$_currentDate = new Zend_Date(); } // dispatch event to determine whether the product will eventually get to the result $product = new Varien_Object(array('allowed_in_rss' => true, 'allowed_price_in_rss' => true)); $args['product'] = $product; Mage::dispatchEvent('rss_catalog_special_xml_callback', $args); if (!$product->getAllowedInRss()) { return; } // add row to result and determine whether special price is active (less or equal to the final price) $row = $args['row']; $row['use_special'] = false; $row['allowed_price_in_rss'] = $product->getAllowedPriceInRss(); if (isset($row['special_to_date']) && $row['final_price'] <= $row['special_price'] && $row['allowed_price_in_rss']) { $compareDate = self::$_currentDate->compareDate($row['special_to_date'], Varien_Date::DATE_INTERNAL_FORMAT); if (-1 === $compareDate || 0 === $compareDate) { $row['use_special'] = true; } } $args['results'][] = $row; }
/** * Preparing data and adding to rss object * * @param array $args */ public function addSpecialXmlCallback($args) { /* * RSS state object */ $product = new Varien_Object(); //Product is allowed for RSS initially $product->setAllowedInRss(true); $args['product'] = $product; Mage::dispatchEvent('rss_catalog_special_xml_callback', $args); if (!$product->getAllowedInRss()) { //Skip adding product to RSS return; } $row = $args['row']; if ($product->getAllowedPriceInRss()) { $specialPrice = $row['special_price']; $rulePrice = $row['rule_price']; if (!$rulePrice || $rulePrice && $specialPrice && $specialPrice <= $rulePrice) { $row['start_date'] = $row['special_from_date']; $row['use_special'] = true; } else { $row['start_date'] = $row['rule_start_date']; $row['use_special'] = false; } $row['allowed_price_in_rss'] = true; } else { $row['start_date'] = null; $row['allowed_price_in_rss'] = false; } $args['results'][] = $row; }