Grunt installation issues on Magento 2

I’ve been trying to install Grunt on Magento 2 and been having little luck.

This was the result of me trying to run

npm install grunt --save-dev
13609 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt" "--save-dev"
13610 error node v4.2.1
13611 error npm  v2.14.7
13612 error code EPEERINVALID
13613 error peerinvalid The package grunt@1.0.1 does not satisfy its siblings' peerDependencies requirements!
13613 error peerinvalid Peer grunt-exec@0.4.6 wants grunt@~0.4
13613 error peerinvalid Peer grunt-styledocco@0.1.6 wants grunt@~0.4
13613 error peerinvalid Peer grunt-contrib-clean@0.6.0 wants grunt@~0.4.0
13613 error peerinvalid Peer grunt-banner@0.4.0 wants grunt@>=0.4.0
13613 error peerinvalid Peer grunt-autoprefixer@2.2.0 wants grunt@~0.4.2
13613 error peerinvalid Peer grunt-contrib-watch@0.6.1 wants grunt@~0.4.0
13613 error peerinvalid Peer grunt-replace@0.9.3 wants grunt@>=0.4.0
13613 error peerinvalid Peer grunt-contrib-connect@0.9.0 wants grunt@~0.4.0
13613 error peerinvalid Peer grunt-contrib-cssmin@0.10.0 wants grunt@~0.4.1
13613 error peerinvalid Peer grunt-contrib-less@0.12.0 wants grunt@~0.4.0
13613 error peerinvalid Peer grunt-contrib-jasmine@0.8.2 wants grunt@~0.4.0
13613 error peerinvalid Peer grunt-contrib-imagemin@0.9.4 wants grunt@>=0.4.0

If I simply change the original command to:

npm install grunt@0.4 --save-dev

It seems to accept it!

Magento | Breadcrumbs aren’t consistent

Never fear. Thanks to Palanikumar, we can override the core files.

Firstly, copy Breadcrumb.php from

app/code/core/Mage/Page/Block/Html

to

app/code/local/Mage/Page/Block/Html

And then replace the function _toHtml() (it should be easy to locate)

with the following updated function.

protected function _toHtml() {             

       $cat_id = "";

       if (Mage::registry('current_product')) {
          $product_id = Mage::registry('current_product')->getId();
          $obj = Mage::getModel('catalog/product');
          $_product = $obj->load($product_id); // Enter your Product Id in $product_id

          if ($product_id) {
             $categoryIds = $_product->getCategoryIds();
             $cat_id = $categoryIds[0];
          }

          $category = Mage::getModel('catalog/category')->load($cat_id);
          $cat_name = $category->getName();
          $cat_url =  $this->getBaseUrl().$category->getUrlPath();
       }

       if (is_array($this->_crumbs)) {
          reset($this->_crumbs);
          $this->_crumbs[key($this->_crumbs)]['first'] = true;
          end($this->_crumbs);
          $this->_crumbs[key($this->_crumbs)]['last'] = true;
       }

       if($cat_id) {
          $this->_crumbs['category'.$cat_id] = array('label'=>$cat_name, 'title'=>'', 'link'=>$cat_url,'first'=>'','last'=>'','readonly'=>'');
          ksort($this->_crumbs);
          $home = $this->_crumbs['home'];
          unset($this->_crumbs['home']);
          array_unshift($this->_crumbs,$home);
       }

       $this->assign('crumbs', $this->_crumbs);
       return parent::_toHtml();
    }

BOOM!

Getting attributes to show on Recently Viewed block.

I created a Recently Viewed block for use on a homepage and I couldn’t for the life of me get the product attributes to feed through.

$man = Mage::getModel('catalog/product')->load($_product->getId())->getManufacturer();
$roundel = Mage::getModel('catalog/product')->load($_product->getId())->getRoundel();
$roundel_txt =  Mage::getModel('catalog/product')->load($_product->getId())->getAttributeText('roundel');

And I could use these attributes within the item!

if ($roundel):
  echo '<div class="product-roundel roundel-' . $roundel . '">'. $roundel_txt .'</div>';
endif;