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

在单个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

图片转代码服务由CSDN问答提供 功能建议

有时我将一些php文件放入magento的根目录,这也是我网站的根目录。 我知道这可能不是最佳做法,但现在这不是我的问题。

例如,我做了一个example.com/calc.php,一个非常具体的计算器 不与任何magento数据交互。 这很好用。

有时候我做了一些与magento数据交互的页面,但都是通过API调用(而且速度很慢!!!!)

 &lt;?php 
 $ user ='mageuser'; 
 $ pass ='magepass'; 
 $ soap = new SoapClient(“http://www.example.com/api/v2_soap  /?wsdl“); 
 $ session = $ soap-&gt; login($ user,$ pass); 
 //然后取消订单,例如
 $ soap-&gt; salesOrderCancel($ session,'100004826  '); 
   
 
 

有没有办法做到这一点,包括magento的类而不是使用API​​来试图让事情变得更快? \ n

提前致谢

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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();
    
    打赏 评论

相关推荐 更多相似问题