List articles
Lists the code and name of all articles of the company, or of the articles that match a pattern. Articles (items) belong to the Classic invoicing module: a sales invoice line refers to an article and one of its sub-articles.
Twinfield documentation: Articles.
search() uses the Finder type ART and gives ArticleSummary results with code and name. all() fetches page after page while you iterate, so it also works for hundreds of articles. Use get() for the settings and the sub-articles (see Read article).
articleVat(ArticleVat::Exclusive) sends the Finder option vat. With that option Twinfield also returns its special items: - (free text), 0 (one-off item) and T (projects).
These are not the sales articles of the REST API: see List sales articles for those.
$twinfield = Example::twinfield();
foreach ($twinfield->articles()->search($pattern)->all() as $article) { echo $article->code, ' ', $article->name, PHP_EOL;}php examples/articles/list-articles/example.phpphp examples/articles/list-articles/example.php 'BIKE*'5DISCOUNT 5% discountBIKE Bike summer editionCONSULT ConsultancyWhat the SDK sends to Twinfield and what Twinfield sends back, for a call like the one in this example. The responses come from the tests, with example data.
Twinfield documentation: Articles: Find.
$twinfield->articles()->search('*BIKE*')->limit(20)->get();The SDK sends this in the SOAP body to finder.asmx, with SOAPAction http://www.twinfield.com/Search; the access token goes in the SOAP header:
<Search xmlns="http://www.twinfield.com/"> <type>ART</type> <pattern>*BIKE*</pattern> <field>0</field> <firstRow>1</firstRow> <maxRows>20</maxRows></Search>Twinfield answers with this SOAP body:
<SearchResponse xmlns="http://www.twinfield.com/"> <SearchResult/> <data> <TotalRows>2</TotalRows> <Columns> <string>Code</string> <string>Naam</string> </Columns> <Items> <ArrayOfString> <string>5DISCOUNT</string> <string>5% discount</string> </ArrayOfString> <ArrayOfString> <string>BIKE</string> <string>Bike summer edition</string> </ArrayOfString> </Items> </data></SearchResponse>Source
Section titled “Source”View examples/articles/list-articles/example.php on GitHub.
Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.