CSS officially needs to be replaced. Centering a dropdown menu should NOT be this hard:
http://matthewjamestaylor.com/blog/centered-dropdown-menus
Thank goodness I found that article or I would still be pulling my hair out.
In my day, used to be you could stick this in one or two tables and you were done. We didn’t have no stinkin’ separation of content and layout and we liked it.
We had a legacy order fulfillment library written in Perl, so although accessing the API is extremely easy in PHP, when we migrated to Magento I had to figure out how to connect to the SOAP API from Perl.
Turns out the most popular CPAN module for doing SOAP in Perl (SOAP::Lite) is not particularly fun to use (see “State of the SOAP” at http://www.soaplite.com/ for a three-year-old call for volunteers to refactor).
Nevertheless, I did eventually emerge victorious. There may be a much easier way but after a lot of head-scratching and trial and error, this worked for me, YMMV.
The soapify routine was stolen from this page:
http://www.soaplite.com/2004/01/building_an_arr.html
Many thanks to soapify author Sandeep Satavlekar.
For passing the filter args to sales_order.list, I had to make the call in PHP first and then reverse-engineer the encoding of the nested array that actually got passed. There may be a way to get SOAP::Lite to encode nested arrays like this by default (or encode nested arrays in some other standard SOAPy way that Magento would also accept) but I chose not to waste any more time on this than I already had.
Enjoy!
UPDATE: Was getting sporadic “Access Denied” errors. Turns out you can fix this just by turning on cookies. Apparently this only affects you if Magento is using DB sessions. See new get_soap_session below for how to turn on cookies.
UPDATE TO THE UPDATE: Nah, that didn’t fix it. Still searching for a fix… runs fine in a session, fails about 80% of the time from cron.
The complete working example script is after the jump...
#!/usr/bin/perl
# replace these values with the soap account you set up in the admin
my $user = 'username';
my $pass = 'password';
# replace with your domain and path (we installed magento at /shop/)
my $soap_url = 'http://YOURDOMAIN/MAGENTO_PATH/index.php/api/index/index/';
my ($soap,$session_id) = &get_soap_session($user,$pass,$soap_url);
# simple example (one arg of type string)
my $oid = '1000001';
my $order = &get_order($soap,$session_id,$oid);
# gnarly example (argument is nested arrays)
my $orders = &get_recent_invoiced_orders($soap,$session_id);
foreach my $ord (@$orders) {
my $due = $ord->{grand_total};
my $paid_or_authorized = $ord->{total_invoiced};
my $owed = $due - $paid_or_authorized;
# ignore if not yet paid
next if ($owed > .02);
&fulfill_order($ord);
}
exit 0;
Continue reading »