Creating a product with image - Shopify API - shopify

I am having a problem with image when creating a product using shopify API
Here is the JSON I try to send using POST
{
"product": {
"title": "Balance 100% Whey Protein 2.8kg w/ FREE Magnesium complete powder",
"body_html": "<p><span><strong>Balance 100% Whey Protein <strong>–</strong> WPC/WPI</strong> is your complete protein source providing you with a technically advanced combination of Whey Protein Concentrate, easily-digested Whey Protein Concentrate and Whey Protein Isolate in a 2:1 ratio.</span></p>",
"vendor": "Balance",
"product_type": "Physical",
"images": [
{
"attachment": "iVBORw0KGgoAAAANSUhEUgAAADIAAABCCAIAAACafxInAAAdXUlEQVR42o16B3gVVfr+OdPL7Tc3PYQAIixVigiCBaTZdnHt6KorKuoiYGHVXRsWUEQFsaCuvayyrIogNkSUKqAiXYIkIQlpt8+dPmd+39ybALI+z/8/hCQ3mTvnna+83/ueCV6FMIcohnJQ14HRsYNyvc8Ee9/Qx/0cu8iF82jsYkq3HD/PszRtqSaFCI0wnA7nGMjCCLOIgpc6dmycvxZyvXcTt/M61LHVXIILa3k//4rmKMehaOK67gmYfhcWrOlStIMZg8Iq5VqUS9O0gDnOcCjdkBB2kKPRrgNvoRiaIM62AaNLFdYjhUX+37C+E3xENxBlI9x1KkEnHDh/Kt11IZNiVCEQp9x2yswiWxAEzkARk4oiSnQNlRhtlJnBSBAY2cYRC/ktTLuEcly4dB4QVQjBURBdsNxjsDb7IraSxdjOhzd/qntctLD3Y+8TRjbNmDSlsWyG4/YmMq3IaUUonQ+wgFAlQt2DIVfNKDZpclEm//YwRtU8qsBsOc3JFuEdmyIQRwAHMaC8JKBjMShEsrA4XkPLkqPnf+2eECS6ECXXJV6hIFMKNHPcz7axW1UyAq2ylOWVEsaYogihLYiHA1GBWzHofOXlS5B3UFRzR3D+P7BCWFWQrYXyIbEwB8gY1zyKzM2/p/ACr2Z8UVvHyPlfWFT+g2U4l+aSDNPAUj/que2W0chgEpTNrhZgWNa2LNO0LNsSRRH9zxHSSWlKG+uPDmAYfzLh91oBQSUAApaQo7BIvrA7o/Vf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kwWNvvvbqGcOH3TPrNtHt3JY54fBgYcI63gM2y4Ui4//7+Zo7HpqbNH8HlpJ18Fv/vPabDRtHDDr18iuuTbrkrvvv2/Tj96LgntQ9woqsAlWVdn/Z12wayHFoysuFDUPqkj9ftHTpCyzj7Pxx20P33wfj+5KL/nj++PGurlMu+f+BtW3fganTp7dkQa6Ao8QhP1VdzUWDrMhLmayJLxtWNvWqq849+zwom1bDvGratEMtdQE/06t7BCRFzmEbmlLNh1Xb9B6o5b20A/8nTxq/7N13oajmP3BfNt4G8bv1pusrykotQztqY49X9HCH2WyatpAgSFDIWJRbsrl/PvHEuyu+Ap3vMT1CgwfzkSC4C8YAybn93Sf79x+ATG9jvMNG10y/YV9dbSBE9+wWgvszkAiwWppUy6AtcCBdS54ypP+Xq1Yf2L79paeemnbF5RQxBw3uD/xp2PrvwMKe1AcLxCOGYiVds1xByiHqs42bZvzj7lTKZHiYx05VOdAEgiTCmPk/yFqi5lsADKAAAAAASUVORK5CYII=",
"filename": "sample_image0001.jpg"
}
],
"tags": [
"Specials",
"Whey Protein Blend (WPI/WPC)",
"Protein Powders",
"Stacks and Packs"
]
}
}
The product is successfully created but the picture wasn't uploaded

The file extension of filename parameter must match the filetype of the attached file. Inspecting the attachment, this seems to be a PNG file, while your filename specifies a JPG. Change this to match the filetype and it should work.

Related

How to restructure positions of product media or remove all images using product api in Shopware

So I have an product and want to change the position of its images and swap the cover image, while adding some more images to the medias assigned to the product.
The media should look somewhat like this:
{
"media": [
{
"id": "a060944a2938442c8d461b3a0107ecf5",
"mediaId": "722d194bfbb84dc489f9f5b74da53bb3",
"position": 1
},
{
"id": "b060944a2938442c8d461b3a0107ecf6",
"mediaId": "822d194bfbb84dc489f9f5b74da53bb4",
"position": 2
}
],
"coverId": "a060944a2938442c8d461b3a0107ecf5"
}
and change to this:
{
"media": [
{
"id": "a060944a2938442c8d461b3a0107ecf5",
"mediaId": "722d194bfbb84dc489f9f5b74da53bb3",
"position": 3
},
{
"id": "b060944a2938442c8d461b3a0107ecf6",
"mediaId": "822d194bfbb84dc489f9f5b74da53bb4",
"position": 2
},
{
"id": "c060944a2938442c8d461b3a0107ecf7",
"mediaId": "922d194bfbb84dc489f9f5b74da53bb5",
"position": 1
}
],
"coverId": "b060944a2938442c8d461b3a0107ecf6"
}
I couldn't find a way to restructure the media positions and change the cover image.
So I tried to remove the media from the product, but the cover image stills stays even though the medias aren't connected to the product any more.
Also an UPDATE on the coverId doesn't seem to do the job either.
I used this to remove the images:
DELETE https://your-page.com/api/product/5efd4f22dc134ba7bf77c85f92fed0a9/media/b060944a2938442c8d461b3a0107ecf6
cover and media are two separate associations, so removing all media associations can still leave the cover association intact.
new ManyToOneAssociationField('cover', 'product_media_id', ProductMediaDefinition::class, 'id')
new OneToManyAssociationField('media', ProductMediaDefinition::class, 'product_id')
Notice how both refer to the definition ProductMediaDefinition. That means for coverId you have to provide the id of an existing product_media entity, not of a media entity.
If you have the id of a media entity, you can also create the product_media entity on the fly:
{
"id": "{productId}",
"cover": {
"mediaId": "{mediaId}"
}
}
If you want to remove the cover image without setting a new one, you can set coverId to null.

Does SurveyJS have a built-in way to specify "show N questions per page"

We are using Survey Creator to allow our users to build questionnaires. However, we want to keep it simple and we don't want them to have to deal with pagination.
In other words, in the builder, we want to disable pages (showPagesToolbox = false) and have them create a set of questions all on a single page.
When we present this to respondents, we want them to see a single question per page. I.e. Q1 is on page 1, Q2 is on page 2, etc.
Does the SurveyJS library provide a way of handling this situation, i.e. here are all the questions, show them with N questions per page?
There is an option, whch allows you to automatically display one question per page. To enable this you need to set "questionsOnPageMode": "questionPerPage" on the survey level. Here's an example:
{
"pages": [
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1"
},
{
"type": "checkbox",
"name": "question2",
"choices": [
"item1",
"item2",
"item3"
]
}
]
}
],
"questionsOnPageMode": "questionPerPage"
}
This is also configurable through the SurveyJS creator by opening the "Survey Settings" dialog, then going to the "Navigation" section, and finally setting the "Questions on page mode" value.
Unfortunately at this time there is no option to specify N number of questions per page. The documentation for this setting is here.

Docusaurus categories in sidebars.json don't show correctly

I have mutiple (more than 2) categories in the sidebars.json,it only render the first and the last one in the page,I can't find how to fix online. thanks.
Here is a producible repo: https://github.com/nianiaJR/doc-demo
Here is my sidebars.json: https://github.com/nianiaJR/doc-demo/blob/master/website/sidebars.json
I expect all navs config in the sidebars.json show in the page. But only the first and the last one show.
{
"type": "subcategory",
"label": "Quick Start",
"ids": [
"doc1",
"doc2",
"doc3"
]
},
{
"type": "subcategory",
"label": "design-and-architecture",
"ids": [
"doc1",
"doc2",
"doc3"
]
}
You have duplicates ids in a different category. You should not do that. The docs is confused whether 'doc1' belong to quick start or design and architecture
https://github.com/nianiaJR/doc-demo/blob/6323eb2207b63cb53918e677681593a9cda9a08d/website/sidebars.json#L13-L29
In my case I had a file named docker-compose.md with an id=docker-compose. My .dockerignore file contained an entry **/docker-compose.
In this case changing the entry to */docker-compose.yml fixed the issue.

Shopify - Get product title in liquid?

In the theme settings the end user is able to select a product from a drop down list of all products. This is done in the settings_scheme.json file.
[
{
{
"name": "Home page - Feature Box 2 (Product 1)",
"settings": [
{
"type": "product",
"id": "homepage-grid-product-1"
}
]
}
]
Then using liquid I want to display the name of the product.
On my page I am using the liquid code:
{{ settings.homepage-grid-product-1 }}
This seems to display the SEO url of the product, how can I make the product title display?
I'm sure this is really straightforward, I am still learning and not quite sure what to look up so not been able to find an answer online.
Cheers, DB.
You can always do a handle lookup via the all_products object.
all_products[settings.my-product-handle]

Google Places API's search results with huge viewports

I have been trying out Google's new Places API. It's "Places Search" returns a list of places close to the latitude/longitude you provide. Each of the results has its actual lat/lang, and some also have "viewports", which are supposed to be the bounding boxes of larger places like stadiums and malls. However, inspecting the viewports on the map, they are way too big. For example, here is a query (it won't work because it doesn't have a real key):
https://maps.googleapis.com/maps/api/place/search/json?location=47.5932,-122.3318&radius=300&sensor=false&key=FOO
Here is part of the result JSON:
{
"status": "OK",
"results": [ {
"name": "Qwest Field",
"vicinity": "Occidental Ave S, Seattle",
"types": [ "stadium", "establishment" ],
"geometry": {
"location": {
"lat": 47.5959329,
"lng": -122.3317095
},
"viewport": {
"southwest": {
"lat": 47.5884079,
"lng": -122.3477169
},
"northeast": {
"lat": 47.6034568,
"lng": -122.3157021
}
}
},
"icon": "http://maps.gstatic.com/mapfiles/place_api/icons/stadium-71.png",
"reference": "CnRrAAAAwM6Pr_ER4VDFNlwg4_JrMxG9FGaqAXokpQXGot9OqzylWRX_NIPsptuMoIeHej9GUDp5otUTQifL-kyP5l0AM5u93PTV22U7-Xz-y_dHuWAjetviEBlo24JIGgWcnuExlE1FBh2FKkNzCdpyUdv7PRIQodCSeacFJtrl8ZkZ1wvfvxoUFCIvCrbknO6tEl3EewS1wrjl06M",
"id": "d4fd94323d3f462730123ac2c5eb91d0180bb819"
},
...
If you look at the lat/langs for the two corners, they are way apart.
I tried a few other places and they all had this problem. Has anybody noticed the same issue?
The 'viewport' property does not represent the bounding box of the place. It represents the recommended map view to use when displaying this place on a Google map. For large features, such as a state or a city it may approximate to the bounds of the feature, but for small features there is a minimum size (~500m across) that is returned, so that the map shows a wide enough area around the feature for a user to understand the location of the place in context.
Hope that helps,
Thor.