Napisałem już wiele modułów wcześniej, ale z jakiegoś powodu mój moduł wysyłki nie zastąpi metody wysyłki magneto. Czy to dozwolone? Czego tu mi brakuje? Nazwa modułu pojawia się w zaawansowanej zakładce obszaru konfiguracji, więc jest ładowana, ale nic się nie dzieje. Jakieś wskazówki?Nadpisywanie metody wysyłki - czego mi brakuje
Kod
etc/modules/Ssi_Shipping.xml
<?xml version="1.0"?>
<config>
<modules>
<Ssi_Shipping>
<active>true</active>
<codepool>local</codepool>
</Ssi_Shipping>
</modules>
</config>
local/Ssi/Spedycja/etc.xml
<?xml version="1.0"?>
<config>
<modules>
<Ssi_Shipping>
<version>0.1.0</version>
</Ssi_Shipping>
</modules>
<global>
<models>
<shipping>
<rewrite>
<carrier_tablerate>Ssi_Shipping_Model_Carrier_Tablerate</carrier_tablerate>
</rewrite>
</shipping>
</models>
</global>
</config>
local/Ssi/Spedycja/Model/Carrier/Tablerate .php
<?php
class Ssi_Shipping_Model_Carrier_Tablerate
extends Mage_Shipping_Model_Carrier_Tablerate {
public function isActive()
{
Mage::log("here! Ssi_Shipping_Model_Carrier_Tablerate");
// check to see if it's disabled
if (parent::isActive() == false)
return false;
// check in the shopping cart
foreach(Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item){
if ($item->getDeliveryFlag() == "test")
return true;
}
// if nothing is found then disable this option.
return false;
}
}
Zdecydowanie nie polecam tego. Jest czysty sposób na zastąpienie przewoźnika, zobacz moją odpowiedź. –