How to call the Magento API from VB.NET

Function getHTTPStream() As String Dim myh As HttpWebRequest = _ HttpWebRequest.Create(“http://yourmagentoweb/soap/api/?wsdl”) myh.Timeout = 30000 myh.UserAgent = “Test” Dim myR As HttpWebResponse = myh.GetResponse() Dim myEnc As Encoding = Encoding.GetEncoding(1252) Dim mySr As StreamReader = New StreamReader(myR.GetResponseStream(), myEnc) Return mySr.ReadToEnd() End Function That code needs tweaking obviously- i have not got time to prettify this stuff … Read more

Skip Checkout in Magento for a downloadable product

This code will allow logged-in customers to “place an order” for a Free, Virtual product while bypassing checkout and redirect them straight to the My Downloads section of their account. Add the following line to your catalog/product/list.phtml in the spot you want it. <?php if($_product->isVirtual() && $_product->getFinalPrice()==0) { ?> <a href=”https://stackoverflow.com/modulename/checkout/purchase/id/<?php echo $_product->getId()?>”><?php echo $this->__(‘Download … Read more

Load block outside Magento, and apply current template

Took me a couple minutes of debugging, but it seems relatively easy. <?php /* * Initialize magento. */ require_once ‘app/Mage.php’; Mage::init(); /* * Add specific layout handles to our layout and then load them. */ $layout = Mage::app()->getLayout(); $layout->getUpdate() ->addHandle(‘default’) ->addHandle(‘some_other_handle’) ->load(); /* * Generate blocks, but XML from previously loaded layout handles must be … Read more

Saving extra data with an order in Magento

After a lot of trial and error – a lot of error – I think I have it now. To begin with the sales_flat_order_grid is updated in Mage_Sales_Model_Mysql4_Order_Abstract::updateGridRecords(), by following the trail I worked out it inspects both the “main” table (sales_flat_order) and the main table + “_grid” (sales_flat_order_grid), takes the intersect of their columns … Read more

How to setup a cron job in Magento module?

In your modules config.xml put the following: <config> <global> <models> <roomstoryinvoicecron> <class>Roomstory_Invoice_Model</class> </roomstoryinvoicecron> </models> </global> <crontab> <jobs> <roomstoryinvoicecron> <schedule> <cron_expr>*/10 * * * *</cron_expr> </schedule> <run> <model>roomstoryinvoicecron/observer::setStatus</model> </run> </roomstoryinvoicecron> </jobs> </crontab> </config> In app/code/local/Roomstory/Invoice/Model/Observer.php add the following: <?php class Roomstory_Invoice_Model_Observer { public function setStatus() { Mage::log(“WORKS!”); } } Make sure logging is enabled and it … Read more

PayPal gateway has rejected request. Security header is not valid (#10002: Security error Magento

The Security header is not valid error is only caused for two reasons: Wrong credentials Make sure that you’ve put your API Username, API Password and API Signature correctly. Sometimes it happens that during copy and paste there is accidently a space added, this would trigger this error. Doublecheck this settings in the SDK or … Read more