Texts
This article contains all actions for retrieving and managing texts.
Tip
The text domain supports fetching related resources.
Get text by ID#
query {
getText(id: "1", include: ["group"]) {
id
siteid
type
domain
languageid
label
content
status
mtime
ctime
editor
lists {
group {
id
item {
id
code
}
}
}
property {
id
type
languageid
value
}
}
}
Aimeos.query(`query {
getText(id: "1", include: ["group"]) {
id
siteid
type
domain
languageid
label
content
status
mtime
ctime
editor
lists {
group {
id
item {
id
code
}
}
}
property {
id
type
languageid
value
}
}
}`).then(data => {
console.log(data)
})
const body = JSON.stringify({'query':
`query {
getText(id: "1", include: ["group"]) {
id
siteid
type
domain
languageid
label
content
status
mtime
ctime
editor
lists {
group {
id
item {
id
code
}
}
}
property {
id
type
languageid
value
}
}
}`});
fetch('<GraphQL URL>', {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': '<CSRF token>'
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"getText": {
"id": "1",
"siteid": "1.",
"type": "short",
"domain": "catalog",
"languageid": "en",
"label": "Best seller short",
"content": "<p>LARGE selection of TOP sellers<br /><strong>BEST prices guaranteed</strong></p>",
"status": 1,
"mtime": "2022-05-28 06:26:35",
"ctime": "2022-05-28 06:26:35",
"editor": "core:setup",
"lists": {
"group": [{
"id": "10",
"item": {
"id": "2",
"code": "wholesale"
}
}]
},
"property": [{
"id": "1",
"type": "from",
"languageid": null,
"value": "manual"
}]
}
}
}
Search texts#
The filter parameter is explained in the filter section of the GraphQL basics article.
query {
searchTexts(filter: "{\\"=~\\": {\\"text.label\\":\\"Demo\\"}}", include: ["group"]) {
items {
id
siteid
type
domain
languageid
label
content
status
mtime
ctime
editor
lists {
group {
id
item {
id
code
}
}
}
property {
id
type
languageid
value
}
}
total
}
}
Aimeos.query(`query {
searchTexts(filter: "{\\"=~\\": {\\"text.label\\":\\"Demo\\"}}", include: ["group"]) {
items {
id
siteid
type
domain
languageid
label
content
status
mtime
ctime
editor
lists {
group {
id
item {
id
code
}
}
}
property {
id
type
languageid
value
}
}
total
}
}`).then(data => {
console.log(data)
})
let filter = {
"=~": {"text.label":"Demo"}
};
const fstr = JSON.stringify(JSON.stringify(filter));
const body = JSON.stringify({'query':
`query {
searchTexts(filter: ` + fstr + `, include: ["group"]) {
items {
id
siteid
type
domain
languageid
label
content
status
mtime
ctime
editor
lists {
group {
id
item {
id
code
}
}
}
property {
id
type
languageid
value
}
}
total
}
}`});
fetch('<GraphQL URL>', {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': '<CSRF token>'
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"searchTexts": {
"items" : [
{
"id": "21",
"siteid": "1.",
"type": "name",
"domain": "supplier",
"languageid": "en",
"label": "Demo name/en: Demo supplier",
"content": "Demo supplier",
"status": 1,
"mtime": "2022-05-28 06:26:38",
"ctime": "2022-05-28 06:26:38",
"editor": "core:setup",
"lists": {
"group": [{
"id": "10",
"item": {
"id": "2",
"code": "wholesale"
}
}]
},
"property": [{
"id": "1",
"type": "from",
"languageid": null,
"value": "manual"
}]
},
{
"id": "22",
"siteid": "1.",
"type": "short",
"domain": "supplier",
"languageid": "en",
"label": "Demo short/en: This is the short description",
"content": "This is the short description of the demo supplier.",
"status": 1,
"mtime": "2022-05-28 06:26:38",
"ctime": "2022-05-28 06:26:38",
"editor": "core:setup",
"lists": {
"group": []
},
"property": []
}
],
"total": 2
}
}
}
Save single text#
mutation {
saveText(input: {
type: "long"
domain: "product"
label: "Test text"
languageid: "en"
content: "This is a long product description."
lists: {
group: [{
refid: "2"
}]
}
property: [{
type: "from"
languageid: null
value: "ERP"
}]
}) {
id
}
}
Aimeos.query(`mutation {
saveText(input: {
type: "long"
domain: "product"
label: "Test text"
languageid: "en"
content: "This is a long product description."
lists: {
group: [{
refid: "2"
}]
}
property: [{
type: "from"
languageid: null
value: "ERP"
}]
}) {
id
}
}`).then(data => {
console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
saveText(input: {
type: "long"
domain: "product"
label: "Test text"
languageid: "en"
content: "This is a long product description."
lists: {
group: [{
refid: "2"
}]
}
property: [{
type: "from"
languageid: null
value: "ERP"
}]
}) {
id
}
}`});
fetch('<GraphQL URL>', {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': '<CSRF token>'
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"saveText": {
"id": "120"
}
}
}
Save multiple texts#
mutation {
saveTexts(input: [{
type: "short"
domain: "catalog"
label: "Test catalog text"
languageid: "en"
content: "This is a short category text."
lists: {
group: [{
refid: "2"
}]
},
property: [{
type: "from"
languageid: null
value: "ERP"
}]
}
{
type: "name"
domain: "product"
label: "Test product name"
languageid: "en"
content: "This is a product name"
}]) {
id
}
}
Aimeos.query(`mutation {
saveTexts(input: [{
type: "short"
domain: "catalog"
label: "Test catalog text"
languageid: "en"
content: "This is a short category text."
lists: {
group: [{
refid: "2"
}]
},
property: [{
type: "from"
languageid: null
value: "ERP"
}]
}
{
type: "name"
domain: "product"
label: "Test product name"
languageid: "en"
content: "This is a product name"
}]) {
id
}
}`).then(data => {
console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
saveTexts(input: [{
type: "short"
domain: "catalog"
label: "Test catalog text"
languageid: "en"
content: "This is a short category text."
lists: {
group: [{
refid: "2"
}]
},
property: [{
type: "from"
languageid: null
value: "ERP"
}]
}
{
type: "name"
domain: "product"
label: "Test product name"
languageid: "en"
content: "This is a product name"
}]) {
id
}
}`});
fetch('<GraphQL URL>', {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': '<CSRF token>'
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"saveTexts": [
{
"id": "121"
},
{
"id": "122"
}
]
}
}
Delete single text#
mutation {
deleteText(id: "120")
}
Aimeos.query(`mutation {
deleteText(id: "120")
}`).then(data => {
console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
deleteText(id: "120")
}`});
fetch('<GraphQL URL>', {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': '<CSRF token>'
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"deleteText": "120"
}
}
Delete multiple texts#
mutation {
deleteTexts(id: ["121", "122"])
}
Aimeos.query(`mutation {
deleteTexts(id: ["121", "122"])
}`).then(data => {
console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
deleteTexts(id: ["121", "122"])
}`});
fetch('<GraphQL URL>', {
method: 'POST',
credentials: 'same-origin',
headers: { // Laravel only
'X-CSRF-TOKEN': '<CSRF token>'
},
body: body
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});
Response:
{
"data": {
"deleteTexts": [
"121",
"122"
]
}
}