Skip to content

Commit

Permalink
firegento#200: check for empty categories and categoryTypes in observ…
Browse files Browse the repository at this point in the history
…er to prevent warning during auto meta generation
  • Loading branch information
borriglione committed Nov 11, 2013
1 parent 35620fb commit 527c15e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/code/community/FireGento/GermanSetup/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,18 @@ public function autogenerateMetaInformation(Varien_Event_Observer $observer)
* Get the categories of the current product
*
* @param Mage_Catalog_Model_Product $product Product
* @return array Categories
* @return string Keywords
*/
protected function _getCategoryKeywords($product)
{
$categories = $product->getCategoryIds();

//Check for empty categories
if (true === empty($categories)) {
return array();
}

//If product categories were given fetch their names and build the keyword string
$categoryArr = $this->_fetchCategoryNames($categories);
$keywords = $this->_buildKeywords($categoryArr);

Expand Down Expand Up @@ -221,6 +228,12 @@ protected function _fetchCategoryNames($categories)
protected function _buildKeywords($categoryTypes)
{
$keywords = '';

//Check for empty category types
if (true === empty($categoryTypes)) {
return $keywords;
}

foreach ($categoryTypes as $categories) {
$keywords .= implode(', ', $categories);
}
Expand Down

0 comments on commit 527c15e

Please sign in to comment.