I'm trying to query for a specific purchase order using the "PurchaseOrderNumber" field, however regardless of what value I provide, all PurchaseOrders are returned.
I've replicated the exact same code except swapped out for Invoices and the querying of "InvoiceNumber" works fine, just not PurchaseOrders.
Here's the URL I'm calling:
https://api.xero.com/api.xro/2.0/PurchaseOrders?where=PurchaseOrderNumber%3D%3D%22PO-0007%22
You can query purchase orders both by Id and Purchase order number.
So your request would look something like
api.xero.com/api.xro/2.0/PurchaseOrders/PO-0001
PO-0001 can be substituted by the actual id as well.
Look at xero documentation here, and the optional parameters section.
Hope this helps.
Related
I'm working on an add-on for a script. It's an old add-on written by someone else I used to know but then just left dead. In my interests of learning more php/sql, I've been working on it. Pretty much, it's a support ticket system.
Right now, there's a file which holds all convenient DB functions when they need to be called. I'm making a page that lists all of the tickets, and their status (New, Answered, so on...), but I'd like to add the name of the Department it was sent to. Admins can make departments, and then users can pick one of these departments when making a ticket. My problem is, however, that the person who left the code never really merged departments with tickets. Here's the ticket code I currently have:
static function ticket_list() {
return OW::getDbo()->queryForList("SELECT id,category_id,subject,requested_deletion,department_id,updated,status FROM ".SupportCenterDB::table_ticket()." ORDER BY updated DESC;");
}
"department_id" is the key factor here. There's a DB table for departments, and a call for "department_get" which is as follows:
static function department_get($id) {
$d=OW::getDbo();
$res=$d->queryForList("SELECT * FROM ".SupportCenterDB::table_department()." WHERE id='".$d->escapeString($id)."';");
return $res[0];
}
So, I call all the tickets as so:
$tickets_q=SupportCenterDB::ticket_list();
$tickets=array();
foreach($tickets_q as $data) {
array_push($tickets,array(
"text"=>$data["subject"],
"updated"=>$data["updated"],
"department"=>$data["department_id"],
"status"=>$this->get_ticket_status($data),
//"url_view"=>"/settings/tickets/view/${data["id"]}",
"url_view"=>OW::getRouter()->urlForRoute("supportcenter-manage-tickets-view",array("id"=>$data["id"])),
"url_delete"=>OW::getRouter()->urlForRoute("supportcenter-manage-tickets-delete",array("id"=>$data["id"])),
"request_deletion"=>$data["requested_deletion"],
));
}
$this->assign("items",$tickets);
This simply only shows the actual id of the selected department when I have the value displayed on the table. In this case, the department's text value is "Support" but the ID is "1". This code shows the department as the id, so as "1". I want to get it so the received $data of the department_id will match with the rest of my Department tables, so that I can actually display the Department text.
Basically, I want to get the value of department_id from each $tickets_q, and have the id match with the text of the corresponding department, so it displays the actual name and not the ID number.
Thanks for your help!
What you're looking for is an Inner Join. You can modify your original query to accomplish this in one statement. This also assumes you don't need the department_id, just the department_name. If you do need it, add it back into your list of fields to fetch.
static function ticket_list() {
$table_ticket = SupportCenterDB::table_ticket();
return OW::getDbo()->queryForList("SELECT id, category_id, subject,
requested_deletion, table_departments.text, updated, status FROM {$table_ticket}
JOIN table_departments ON table_departments.id = {$table_ticket}.department_id
ORDER BY updated DESC;");
}
Note: You should really look into using a prepared statement for the SQL query, that way you're not passing in a parameter directly into your select statement, even if it is defined right above it.
Update:
"department"=>$data["department_id"] needs to become "department"=>$data["text"]. To be cleaner, you could give the field an alias so you know what you're actually pulling.
SELECT id, category_id, ..., table_departments.text AS department_name, updated, status...
And then the line above becomes "department"=>$data["department_name"].
I know I can do something like:
SELECT * FROM Customer
which returns the following objects.
Active
AlternatePhone
Balance
BalanceWithJobs
BillAddr
BillWithParent
CompanyName
CurrencyRef
DefaultTaxCodeRef
DisplayName
FullyQualifiedName
Id
Job
MetaData
PreferredDeliveryMethod
PrimaryEmailAddr
PrimaryPhone
PrintOnCheckName
ShipAddr
SyncToken
Taxable
I tried limiting my query to:
SELECT Id FROM Customer which worked great, but for some reason I cannot do:
SELECT ShipAddr FROM Customer. No data is returned.
I've learned SELECT DisplayName, Id FROM Customer works but nothing else does.
Is there a way I can request the following data only and nothing else:
SELECT AlternativePhone, BillAddr, CompanyName, DisplayName, Id, PrimaryEmailAddr, PrimaryPhone, ShipAddr FROM Customer?
I do not think fetching only selective fields is supported for all fields.
You can try your queries on API explorer and see if get the resultset you want. Else, please consider it as non-supported.
You will have to get the full response in that case then and use the selected fields/properties.
I'm trying to make a custom-feed from my companies Facebook page to our website. I query the Graph API of Facebook to get this information.
Facebook changed the API a while ago to not include like counts in the normal page query. In the documentation it says to add summary=1 to get the total likes. My query does not return the total_count tho when I query it.
I am omitting my acces_token in the queries because I'm using the API Explorer.
Query I use to get posts:
Raafh/posts?limit=4
trying to add summary=1 does nothing with the query.
I can however do another query which will return the likes and the total count, but not the post info so I can't use it, or I have to use two queries.
Raafh/posts?fields=likes.summary(1).limit(1)
This posts the last like + the total_count.
How can I combine these two in one query?
You can add required fields in comma separated format to get post data like shown in example below.
Raafh/posts?fields=likes.summary(1).limit(1),id,message,from,picture,link,name,caption,description
I have a module that takes a feed from another site and then imports the orders into magento. The problem is that despite the orders being created properly and appering in Magento they don't show up in the Products Ordered report.
The reason seems to be that this report looks at the sales_flat_quote_item table to produce its results but there is no entry for my sale items. They do however appear correctly in sales_flat _order_item.
Below is a shortened version of the code.
Any suggestions as to why im not getting an entry in flat_quote_item?
Why does the Magento model used by the Ordered Products report use the quote table and not the order table?
$quote = Mage::getModel('sales/quote')->setStoreId((string) $dataArray->StoreviewId);
if (is_object($product)) {
$product->setPrice(((string) $orderitem->Price) / $reverseRate);
$item = Mage::getModel('sales/quote_item');
$item->setQuote($quote)->setProduct($product);
$item->setData('qty', (string) $orderitem->Quantity);
$item->setCustomPrice((string) $orderitem->Price);
$item->setOriginalCustomPrice((string) $orderitem->Price);
$quote->addItem($item);
}
This code doesn't show any calls to $item->save or $quote->save, so it could be that you aren't saving the quote object.
Why does the Magento model used by the Ordered Products report use the quote table and not the order table?
Because you could have an order, which wasn't paid or was canceled and thus the product wasn't delivered. You still have an order in the system, it just wasn't executed.
My guess is, that the specific report should only contain successful order, where the products were shipped or at least the quote was sent.
Any suggestions as to why im not getting an entry in flat_quote_item?
You need to generate the quote, which isn't done automatically on saving an order.
See the following forums thread to get hints on how to generate the quote: http://www.magentocommerce.com/boards/viewthread/28426/P30/
I'm using a lookup table as described in the blog tutorial. So one of my grid columns looks like this:
array(
'name'=>'status',
'value'=>'Lookup::item("PostStatus",$data->status)',
),
If I type "Published" in the Gii generated CRUD filtering system I get nothing. If I type the status code, like 1, I get the correct results.
How can I fix this? I mean I need to be able to type "Published" or "Draft" instead of 1 and 2.
You should provide more information like #Sukumar suggested, however I have kind of a supposition: if status is a number and you are directly writing down that number, I think something like this could be happening:
You write the desired status code
Somehow you pass that number to $data->status
Lookup searches an item with that status as status (just like the id)
Yii gets that number and returns a PostStatus given by that id.
I'm not used to that Lookup::item function, but you should find the way to pass inside the function the statusname (I don't know how you call its name).
I'm sorry, but that's all I can find with that amount of information. I hope it helps