Skip to content

Commit

Permalink
Mage_Rss - DOC block update (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored Mar 12, 2021
1 parent a703c8a commit 48fe4d8
Show file tree
Hide file tree
Showing 18 changed files with 107 additions and 20 deletions.
14 changes: 14 additions & 0 deletions app/code/core/Mage/Rss/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Class Mage_Rss_Block_Abstract
*
* @method int getStoreId()
*/
class Mage_Rss_Block_Abstract extends Mage_Core_Block_Template
{
/**
* @return int
* @throws Mage_Core_Model_Store_Exception
*/
protected function _getStoreId()
{
//store id is store view id
Expand All @@ -35,6 +45,10 @@ protected function _getStoreId()
return $storeId;
}

/**
* @return int
* @throws Exception
*/
protected function _getCustomerGroupId()
{
//customer group id
Expand Down
5 changes: 5 additions & 0 deletions app/code/core/Mage/Rss/Block/Catalog/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ protected function _construct()
$this->setCacheLifetime(600);
}

/**
* @return string
* @throws Mage_Core_Exception
* @throws Mage_Core_Model_Store_Exception
*/
protected function _toHtml()
{
$categoryId = $this->getRequest()->getParam('cid');
Expand Down
6 changes: 6 additions & 0 deletions app/code/core/Mage/Rss/Block/Catalog/New.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ protected function _construct()
//$this->setCacheLifetime(600);
}

/**
* @return string
* @throws Mage_Core_Exception
* @throws Mage_Core_Model_Store_Exception
* @throws Zend_Date_Exception
*/
protected function _toHtml()
{
$storeId = $this->_getStoreId();
Expand Down
3 changes: 1 addition & 2 deletions app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ protected function _toHtml()
$globalNotifyStockQty = (float) Mage::getStoreConfig(
Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
Mage::helper('rss')->disableFlat();
/* @var $product Mage_Catalog_Model_Product */
/* @var Mage_Catalog_Model_Product $product */
$product = Mage::getModel('catalog/product');
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$collection = $product->getCollection();
Mage::getResourceModel('cataloginventory/stock')->addLowStockFilter($collection, array(
'qty',
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Rss/Block/Catalog/Salesrule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ protected function _toHtml()
$lang = Mage::getStoreConfig('general/locale/code');
$title = Mage::helper('rss')->__('%s - Discounts and Coupons',Mage::app()->getStore($storeId)->getName());

/** @var $rssObject Mage_Rss_Model_Rss */
/** @var Mage_Rss_Model_Rss $rssObject */
$rssObject = Mage::getModel('rss/rss');
/** @var $collection Mage_SalesRule_Model_Resource_Rule_Collection */
/** @var Mage_SalesRule_Model_Resource_Rule_Collection $collection */
$collection = Mage::getModel('salesrule/rule')->getResourceCollection();

$data = array(
Expand Down
8 changes: 6 additions & 2 deletions app/code/core/Mage/Rss/Block/Catalog/Special.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ protected function _construct()
$this->setCacheLifetime(600);
}

/**
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
protected function _toHtml()
{
//store id is store view id
Expand Down Expand Up @@ -187,8 +191,8 @@ public function addSpecialXmlCallback($args)
/**
* Function for comparing two items in collection
*
* @param Varien_Object $item1
* @param Varien_Object $item2
* @param Varien_Object $a
* @param Varien_Object $b
* @return boolean
*/
public function sortByStartDate($a, $b)
Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Rss/Block/Catalog/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ protected function _construct()
$this->setCacheLifetime(600);
}

/**
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
protected function _toHtml()
{
//store id is store view id
Expand Down
24 changes: 19 additions & 5 deletions app/code/core/Mage/Rss/Block/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Mage_Rss_Block_List extends Mage_Core_Block_Template
*/
protected function _prepareLayout()
{
/** @var Mage_Page_Block_Html_Head $head */
$head = $this->getLayout()->getBlock('head');
$feeds = $this->getRssMiscFeeds();
if ($head && !empty($feeds)) {
Expand All @@ -58,7 +59,7 @@ protected function _prepareLayout()
/**
* Retrieve rss feeds
*
* @return array
* @return array|false
*/
public function getRssFeeds()
{
Expand All @@ -68,9 +69,12 @@ public function getRssFeeds()
/**
* Add new rss feed
*
* @param string $url
* @param string $label
* @return Mage_Core_Helper_Abstract
* @param string $url
* @param string $label
* @param array $param
* @param bool $customerGroup
* @return $this
* @throws Mage_Core_Model_Store_Exception
*/
public function addRssFeed($url, $label, $param = array(), $customerGroup=false)
{
Expand All @@ -93,11 +97,18 @@ public function resetRssFeed()
$this->_rssFeeds=array();
}

/**
* @return int
* @throws Mage_Core_Model_Store_Exception
*/
public function getCurrentStoreId()
{
return Mage::app()->getStore()->getId();
}

/**
* @return int
*/
public function getCurrentCustomerGroupId()
{
return Mage::getSingleton('customer/session')->getCustomerGroupId();
Expand Down Expand Up @@ -130,6 +141,9 @@ public function getRssCatalogFeeds()
*/
}

/**
* @return array|false
*/
public function getRssMiscFeeds()
{
$this->resetRssFeed();
Expand Down Expand Up @@ -183,7 +197,7 @@ public function CategoriesRssFeed()
if((bool)Mage::getStoreConfig($path)){
$category = Mage::getModel('catalog/category');

/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
/* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection $collection */
$treeModel = $category->getTreeModel()->loadNode(Mage::app()->getStore()->getRootCategoryId());
$nodes = $treeModel->loadChildren()->getChildren();

Expand Down
7 changes: 7 additions & 0 deletions app/code/core/Mage/Rss/Block/Order/New.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ protected function _construct()
$this->setCacheLifetime(600);
}

/**
* @return string
* @throws Mage_Core_Exception
*/
protected function _toHtml()
{
$order = Mage::getModel('sales/order');
Expand Down Expand Up @@ -82,6 +86,9 @@ protected function _toHtml()
return $rssObj->createRssXml();
}

/**
* @param array $args
*/
public function addNewOrderXmlCallback($args)
{
$rssObj = $args['rssObj'];
Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Rss/Block/Order/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ protected function _construct()
$this->setCacheLifetime(600);
}

/**
* @return string
*/
protected function _toHtml()
{
$rssObj = Mage::getModel('rss/rss');
Expand Down
5 changes: 2 additions & 3 deletions app/code/core/Mage/Rss/Block/Wishlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function _getTitle()
*/
protected function _toHtml()
{
/* @var $rssObj Mage_Rss_Model_Rss */
/* @var Mage_Rss_Model_Rss $rssObj */
$rssObj = Mage::getModel('rss/rss');

if ($this->_getWishlist()->getId()) {
Expand All @@ -128,9 +128,8 @@ protected function _toHtml()
'language' => $lang
));

/** @var $wishlistItem Mage_Wishlist_Model_Item*/
/** @var Mage_Wishlist_Model_Item $wishlistItem */
foreach ($this->getWishlistItems() as $wishlistItem) {
/* @var $product Mage_Catalog_Model_Product */
$product = $wishlistItem->getProduct();
$productUrl = $this->getProductUrl($product);
$product->setAllowedInRss(true);
Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Rss/Helper/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
class Mage_Rss_Helper_Catalog extends Mage_Core_Helper_Abstract
{

/**
* @return string
*/
public function getTagFeedUrl()
{
$url = '';
Expand Down
6 changes: 2 additions & 4 deletions app/code/core/Mage/Rss/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,13 @@ public function authFailed()
/**
* Disable using of flat catalog and/or product model to prevent limiting results to single store. Probably won't
* work inside a controller.
*
* @return null
*/
public function disableFlat()
{
/* @var $flatHelper Mage_Catalog_Helper_Product_Flat */
/* @var Mage_Catalog_Helper_Product_Flat $flatHelper */
$flatHelper = Mage::helper('catalog/product_flat');
if ($flatHelper->isAvailable()) {
/* @var $emulationModel Mage_Core_Model_App_Emulation */
/* @var Mage_Core_Model_App_Emulation $emulationModel */
$emulationModel = Mage::getModel('core/app_emulation');
// Emulate admin environment to disable using flat model - otherwise we won't get global stats
// for all stores
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Rss/Helper/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getOrderByStatusUrlKey($key)
$incrementId = intval($data['increment_id']);
$customerId = intval($data['customer_id']);

/** @var $order Mage_Sales_Model_Order */
/** @var Mage_Sales_Model_Order $order */
$order = Mage::getModel('sales/order')->load($orderId);

if (!is_null($order->getId())
Expand Down
18 changes: 18 additions & 0 deletions app/code/core/Mage/Rss/Model/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,47 @@ class Mage_Rss_Model_Rss
{
protected $_feedArray = array();

/**
* @param array $data
* @return $this
*/
public function _addHeader($data = array())
{
$this->_feedArray = $data;
return $this;
}

/**
* @param $entries
* @return $this
*/
public function _addEntries($entries)
{
$this->_feedArray['entries'] = $entries;
return $this;
}

/**
* @param $entry
* @return $this
*/
public function _addEntry($entry)
{
$this->_feedArray['entries'][] = $entry;
return $this;
}

/**
* @return array
*/
public function getFeedArray()
{
return $this->_feedArray;
}

/**
* @return string
*/
public function createRssXml()
{
try {
Expand Down
9 changes: 9 additions & 0 deletions app/code/core/Mage/Rss/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
* @category Mage
* @package Mage_Rss
* @author Magento Core Team <core@magentocommerce.com>
*
* @method Mage_Admin_Model_User getAdmin()
* @method Mage_Customer_Model_Customer getCustomer()
*/
class Mage_Rss_Model_Session extends Mage_Core_Model_Session_Abstract
{
Expand All @@ -39,11 +42,17 @@ public function __construct()
$this->init('rss');
}

/**
* @return bool
*/
public function isAdminLoggedIn()
{
return $this->getAdmin() && $this->getAdmin()->getId();
}

/**
* @return bool
*/
public function isCustomerLoggedIn()
{
return $this->getCustomer() && $this->getCustomer()->getId();
Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Rss/controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function newAction()
}
}

/**
* @return $this|void
* @throws Mage_Core_Model_Store_Exception
*/
public function customerAction()
{
if ($this->checkFeedEnable('order/customer')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/


/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */

$installer = $this;

Expand Down

0 comments on commit 48fe4d8

Please sign in to comment.