2

When I disable a product and access the product by full category URL I am sent to a 404 page. Good.

When I attempt to access the disabled product by http://domain.com/disabled-product.html I get

Fatal error: Call to a member function getMetaTitle() on a non-object in /app/code/core/Mage/Catalog/Block/Product/View.php on line 57

Could it be that an extension is attempting to load prior to the redirect?

EDIT: Lines 50-59

protected function _prepareLayout()
{
    $this->getLayout()->createBlock('catalog/breadcrumbs');
    $headBlock = $this->getLayout()->getBlock('head');
    if ($headBlock) {
        $product = $this->getProduct();
        $title = $product->getMetaTitle();
        if ($title) {
            $headBlock->setTitle($title);
        }
 ...
}
  • What extensions you have installed? Have someone edited the core classes? – Amasty Aug 18 '14 at 18:57
  • Please add the code around line 57 – Renon Stewart Aug 18 '14 at 19:00
  • I have added the code. I've just taken over this project so it is hard for me to say which files have and have not been touched. I assume it is a block loading without ensuring it is in the proper place - but I do not know that for sure. – TylersSN Aug 18 '14 at 19:03
3

This was due to a conflic with FME Ajax Add to cart.

I resolved by commenting out this rewrite in /app/code/local/FME/Ajaxaddtocart/etc/config.xml:

<!--
    Rewrite disabled because it conflicted with CreareSEO redirects
    <rewrite>

    <fme_ajaxaddtocart_productcontroller>
    <from><![CDATA[#^catalog/product/#]]></from>
    <to>/ajaxaddtocart/product/</to>
    </fme_ajaxaddtocart_productcontroller>

</rewrite> -->
  • If this was the solution, and it does seem like a more correct solution, why did you accept the other answer? – Goose Apr 28 '16 at 15:58
2

Product is not an object, so try changing

if ($headBlock) {
    $product = $this->getProduct();
    $title = $product->getMetaTitle();
    if ($title) {
        $headBlock->setTitle($title);
    }

To

if ($headBlock) {
    $product = $this->getProduct();
    if($product){
        $title = $product->getMetaTitle();
        if ($title) {
           $headBlock->setTitle($title);
         }
  • 2
    Can we assume that the root problem of this was a block loading out of order? It seems like magento core should have this check in place. – TylersSN Aug 18 '14 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.