title: How do you overide a class that is called by another class with parent::method
body: <p>I am trying to extend Mage_Catalog_Block_Product_View I have it setup in my version of it in my local directory and everything works fine, but I wasn't getting the results that I wanted. I then saw that another class extended that class as well. Which seemed to reset whatever got set from my class. I know that my class is working fine and executing. Its just that there is another class that is a child of the same class I am extending and calling parent::method to the same method I am overriding, that class gets executed after my class and when it does that, it is running the original method that I am overriding and not mine</p>
  
  <p>This is the function </p>
  
  <pre><code>class Mage_Review_Block_Product_View extends Mage_Catalog_Block_Product_View
  protected function _prepareLayout()
  {
      $this-&amp;gt;getLayout()-&amp;gt;createBlock('catalog/breadcrumbs');
      $headBlock = $this-&amp;gt;getLayout()-&amp;gt;getBlock('head');
      if ($headBlock) {
          $title = $this-&amp;gt;getProduct()-&amp;gt;getMetaTitle();
          if ($title) {
              $headBlock-&amp;gt;setTitle($title);
          }
          $keyword = $this-&amp;gt;getProduct()-&amp;gt;getMetaKeyword();
          $currentCategory = Mage::registry('current_category');
          if ($keyword) {
              $headBlock-&amp;gt;setKeywords($keyword);
          } elseif($currentCategory) {
              $headBlock-&amp;gt;setKeywords($this-&amp;gt;getProduct()-&amp;gt;getName());
          }
          $description = $this-&amp;gt;getProduct()-&amp;gt;getMetaDescription();
          if ($description) {
              $headBlock-&amp;gt;setDescription( ($description) );
          } else {
              $headBlock-&amp;gt;setDescription( $this-&amp;gt;getProduct()-&amp;gt;getDescription() );
          }
      }
  
      return parent::_prepareLayout();
  }
  </code></pre>
  
  <p>I am trying to modify it just a bit with the following, keep in mind I know there is a title prefix and suffix but I needed it only for the product page and also I needed to add text to the description.</p>
  
  <pre><code>class MyCompany_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_View
  protected function _prepareLayout()
  {
      $storeId = Mage::app()-&amp;gt;getStore()-&amp;gt;getId();
      $this-&amp;gt;getLayout()-&amp;gt;createBlock('catalog/breadcrumbs');
      $headBlock = $this-&amp;gt;getLayout()-&amp;gt;getBlock('head');
      if ($headBlock) {
          $title = $this-&amp;gt;getProduct()-&amp;gt;getMetaTitle();
          if ($title) {
              if($storeId == 2){
                  $title = "Pool Supplies Fast - "  .$title;
              $headBlock-&amp;gt;setTitle($title);
          }
              $headBlock-&amp;gt;setTitle($title);
          }else{
              $path  = Mage::helper('catalog')-&amp;gt;getBreadcrumbPath();
  
              foreach ($path as $name =&amp;gt; $breadcrumb) {
                  $title[] = $breadcrumb['label'];
              }
               $newTitle = "Pool Supplies Fast - "  . join($this-&amp;gt;getTitleSeparator(), array_reverse($title));
              $headBlock-&amp;gt;setTitle($newTitle);
          }
          $keyword = $this-&amp;gt;getProduct()-&amp;gt;getMetaKeyword();
          $currentCategory = Mage::registry('current_category');
          if ($keyword) {
              $headBlock-&amp;gt;setKeywords($keyword);
          } elseif($currentCategory) {
              $headBlock-&amp;gt;setKeywords($this-&amp;gt;getProduct()-&amp;gt;getName());
          }
          $description = $this-&amp;gt;getProduct()-&amp;gt;getMetaDescription();
          if ($description) {
              if($storeId == 2){
                  $description = "Pool Supplies Fast - ". $this-&amp;gt;getProduct()-&amp;gt;getName() . " - " . $description;
                  $headBlock-&amp;gt;setDescription( ($description) );
              }else{
                $headBlock-&amp;gt;setDescription( ($description) );
              }
  
          } else {
               if($storeId == 2){
                   $description = "Pool Supplies Fast: ". $this-&amp;gt;getProduct()-&amp;gt;getName() . " - " . $this-&amp;gt;getProduct()-&amp;gt;getDescription();
                  $headBlock-&amp;gt;setDescription( ($description) );
              }else{
                $headBlock-&amp;gt;setDescription( $this-&amp;gt;getProduct()-&amp;gt;getDescription() );
              }
  
          }
      }
  
      return Mage_Catalog_Block_Product_Abstract::_prepareLayout();
  }
  </code></pre>
  
  <p>This executs fine but then I notice that the following class Mage_Review_Block_Product_View_List extends which extends Mage_Review_Block_Product_View and that extends Mage_Catalog_Block_Product_View as well. Inside this class they call the _prepareLayout as well and call the parent with parent::_prepareLayout()</p>
  
  <pre><code>class Mage_Review_Block_Product_View_List extends Mage_Review_Block_Product_View
  protected function _prepareLayout()
  {
      parent::_prepareLayout();
  
      if ($toolbar = $this-&amp;gt;getLayout()-&amp;gt;getBlock('product_review_list.toolbar')) {
          $toolbar-&amp;gt;setCollection($this-&amp;gt;getReviewsCollection());
          $this-&amp;gt;setChild('toolbar', $toolbar);
      }
  
      return $this;
  }
  </code></pre>
  
  <p>So obviously this just calls the same class I am extending and runs the function I am overiding but it doesn't get to my class because it is not in my class hierarchy and since it gets called after my class all the stuff in the parent class override what I have set. </p>
  
  <p>I'm not sure about the best way to extend this type of class and method, there has to be a good way to do this, I keep finding I am running into issues when trying to overide these prepare methods that are derived from the abstract classes, there seems to be so many classes overriding them and calling parent::method.</p>
  
  <p>What is the best way to override these functions?</p>