duanmeng3573 2015-11-12 18:48
浏览 73
已采纳

在单个PHP页面中使用Magento类

Some times i put some php files into my magento's root directory, which is my site's root directory too. I know this may not be best practice, but that is not the point of my question now.

For example, I have made one example.com/calc.php , a very specific calculator that does not interact with any magento data. That works OK.

Some times I did some pages with interaction with magento's data, but all through API calls (and is so slow!!!!)

<?php
$user='mageuser';
$pass='magepass';
$soap = new SoapClient("http://www.example.com/api/v2_soap/?wsdl");
$session = $soap->login($user, $pass);
// and then cancel an order for example
$soap->salesOrderCancel($session, '100004826');

Is it there a way to do this including magento's classes instead of using the API to try to make things faster?

Thanks in advance

  • 写回答

1条回答 默认 最新

  • doudi1978 2015-11-12 20:02
    关注
    <?php
    
    require_once 'app/Mage.php';
    umask(0);
    
    Mage::app();
    
    $order = Mage::getModel('sales/order')->loadByIncrementId('100004826');
    $order->cancel();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我调试idea基于spring boot项目
  • ¥15 es 7.17.20版本生成时间戳
  • ¥15 wpf dategrid表头排序图标自定义
  • ¥15 分析下图所示同步时序逻辑电路的逻辑功能。
  • ¥15 halcon联合c#遇到了问题不能解决
  • ¥15 xshell无法连接提示ssh服务器拒绝密码
  • ¥15 AT89C52单片机C语言关于串口通信的位操作
  • ¥20 需要步骤截图(标签-服务器|关键词-map)
  • ¥50 gki vendor hook
  • ¥15 灰狼算法和蚁群算法如何结合