как мне начать? hrmmmm.
хорошо, сейчас я пытаюсь расширить mage_sales_mode_order. но эта ошибка появляется.
Неустранимая ошибка: вызов функции-члена load () для необъекта в /app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php в строке 74
я не знаю, в чем проблема, потому что я уже пытаюсь использовать один и тот же код, чтобы расширить другой сайт magento, но работает.
но ниже это то, что я делаю, и спасибо заранее.
MageCustom / Продажа / Модель / Order.php
class MageCustom_Sales_Model_Order extends Mage_Sales_Model_Order
{
public function queueNewOrderEmail($forceMode = false)
{
$storeId = $this->getStore()->getId();if (!Mage::helper('sales')->canSendNewOrderEmail($storeId)) {
return $this;
}
// Get the destination email addresses to send copies to
$copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
$copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId);
// Start store emulation process
/** @var $appEmulation Mage_Core_Model_App_Emulation */
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
try {
// Retrieve specified view block from appropriate design package (depends on emulated store)
$paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
} catch (Exception $exception) {
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
throw $exception;
}
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
// Retrieve corresponding email template id and customer name
if ($this->getCustomerIsGuest()) {
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
$customerName = $this->getBillingAddress()->getName();
} else {
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
$customerName = $this->getCustomerName();
}
/** @var $mailer Mage_Core_Model_Email_Template_Mailer */
$mailer = Mage::getModel('core/email_template_mailer');
/** @var $emailInfo Mage_Core_Model_Email_Info */
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($this->getCustomerEmail(), $customerName);
if ($copyTo && $copyMethod == 'bcc') {
// Add bcc to customer email
foreach ($copyTo as $email) {
$emailInfo->addBcc($email);
}
}
$mailer->addEmailInfo($emailInfo);
// Email copies are sent as separated emails if their copy method is 'copy'
if ($copyTo && $copyMethod == 'copy') {
foreach ($copyTo as $email) {
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($email);
$mailer->addEmailInfo($emailInfo);
}
}
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId($templateId);
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
));
/** @var $emailQueue Mage_Core_Model_Email_Queue */
$emailQueue = Mage::getModel('core/email_queue');
$emailQueue->setEntityId($this->getId())
->setEntityType(self::ENTITY)
->setEventType(self::EMAIL_EVENT_NAME_NEW_ORDER)
->setIsForceCheck(!$forceMode);
//$mailer->setQueue($emailQueue)->send();
$mailer->send();
Mage::log('new order trigger email', null, 'email.log');
$this->setEmailSent(true);
$this->_getResource()->saveAttribute($this, 'email_sent');
return $this;
}
MageCustom / Продажа / и т.д. / config.xml
<config>
<modules>
<MageCustom_Sales>
<version>0.1.0</version>
</MageCustom_Sales>
</modules>
<global>
<models>
<MageCustom_Sales>
<class>MageCustom_Sales_Model</class>
</MageCustom_Sales>
<sales>
<rewrite>
<order>MageCustom_Sales_Model_Order</order>
</rewrite>
</sales>
</models>
</global>
</config>
MageCustom_Sales.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MageCustom_Sales>
<active>false</active>
<codePool>local</codePool>
</MageCustom_Sales>
</modules>
</config>
Ваш класс и конфигурация верны, если они существуют в app/code/local
кроме active
установка в MageCustom_Sales.xml
:
<active>false</active>
Включите, очистите кеш и попробуйте еще раз 🙂
Если у вас есть magerun, Вы можете использовать его для проверки вашей перезаписи:
n98-magerun.phar dev: class: lookup модель продажи / заказ # Модель продаж / заказ разрешается в MageCustom_Sales_Model_Order
Если вы не видите указанное выше разрешение, у вас могут возникнуть конфликты с перезаписью, но более вероятно, что ваша конфигурация перезаписи неверна.
Если у вас нет Magerun — получите его! Вы не пожалеете об этом.
Вы можете добавить собственный скрипт в корневой каталог вашего проекта Magento просто для проверки псевдонима класса:
<?php
include 'app/Mage.php';
Mage::app();
var_dump(get_class(Mage::getModel('sales/order')));
Запустите его из командной строки через php myTestFile.php
или из браузера через http://magento.local/myTestFile.php
,
Если это работает, вы должны увидеть string(28) "MageCustom_Sales_Model_Order"
, Если этого не произойдет, вы увидите bool(false)
,
Надеюсь это поможет.
Убедитесь, что ваш собственный модуль находится внутри локальной папки, и включите его, вставив true в активный тег.
<active>true</active>