0

So I am trying to override an extension that we installed from MagentoConnect. Its just a tiny little nuance but its important to our plans. So this is what I have so far.

Blizzardlabs/Block/Affiliateplusext.php

class Blizzardlabs_Affiliateplusext_Block_Affiliateplusext extends Magestore_Affiliatepluscoupon_Block_Affiliatepluscoupon {

  public function getListProgram() {die();
    $listProgram = array();
    if (floatval($this->_getConfigHelper()->getGeneralConfig('discount')) >= 0) {
      $listProgram['default'] = new Varien_Object(array(
          'name' => $this->__('Affiliate Program'),
          'commission_type' => $this->_getConfigHelper()->getGeneralConfig('commission_type'),
          'commission' => $this->_getConfigHelper()->getGeneralConfig('commission'),
          'discount_type' => $this->_getConfigHelper()->getGeneralConfig('discount_type'),
          'discount' => $this->_getConfigHelper()->getGeneralConfig('discount'),
          'coupon_code' => $this->getAccount()->getCouponCode()
      ));
    }
    if ($this->isMultiProgram()) {
      $collection = Mage::getResourceModel('affiliateplusprogram/program_collection')
              ->setStoreId(Mage::app()->getStore()->getId());
      $programCoupons = Mage::registry('program_coupon_codes');
      foreach ($collection as $item) {
        if ($item->getStatus() && isset($programCoupons[$item->getId()])) {
          $item->setCouponCode($programCoupons[$item->getId()]);
          $listProgram[$item->getId()] = $item;
        }
      }
    }
    return $listProgram;
  }

}

Here is my configuration

Blizzardlabs/etc/config.xml

<config>
  <modules>
    <Blizzardlabs_Affiliateplusext>
      <version>0.1.0</version>
    </Blizzardlabs_Affiliateplusext>
  </modules>
  <global>
    <blocks>
      <affiliatepluscoupon>
        <rewrite>
          <coupon>Blizzardlabs_Affiliateplusext_Block_Affiliateplusext</coupon>
        </rewrite>        
      </affiliatepluscoupon>
    </blocks>
  </global>
</config>

Here is my module declaration:

app/etc/modules/Blizzardlabs_Affiliateplusext.xml

<config>
    <modules>
        <Blizzardlabs_Affiliateplusext>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
              <Magestore_Affiliatepluscoupon />
            </depends>
        </Blizzardlabs_Affiliateplusext>        
    </modules>
</config>

So, I am calling a on the original module in the module declaration. I THINK im overwriting it correctly in my config and im also extending the original class in my class. Yet it refuses to pick it up. I have a feeling my issue is in my configuration. I think I am overriding it wrong there but I am not sure how. This is my first time so I apologize if its glaringly obvious.

1

So the answer was pretty simple. In config.xml my code needed to be like this:

  <global>
    <blocks>
      <affiliatepluscoupon>
        <rewrite>
          <affiliatepluscoupon>Blizzardlabs_Affiliateplusext_Block_Affiliateplusext</affiliatepluscoupon>
        </rewrite>        
      </affiliatepluscoupon>
    </blocks>
  </global>

I was going off of a helper call ('affiliatecouponplus/coupon') when this is a block. When thinking about it logically this made sense. I changed this and it is working fine now. I will add this as the answer when I can.

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.