I am trying to delete a product using API call but it throws an error saying
"This product cannot be deleted because it has one or more user-created prices."
I checked in stripe documentation but there is no API for deleting the Price.
I recommend that you do not delete product and price objects; instead, archive them by marking them as inactive. You can do this by setting active to false on the Price or Product if you don't want to use them again.
Reference: https://pupuweb.com/solved-fix-stripe-payment-dev-error-delete-price/
Related
I am using storefront API for my Shopify store.
And need to retrieve product metafields for my product.
I already added metafields using 3rd party app(Metafields Guru).
I need to get all those metafields for product, and had been following this article.
https://shopify.dev/tutorials/retrieve-metafields-with-storefront-api
{
productByHandle(handle: "xxx-handle") {
id
title
handle
productType
metafields(first: 5) {
edges {
node {
key
value
}
}
}
}
}
But I get an empty array for metafields.
Not sure what I am missing here.
Any help would be appreciated
There are a couple of problems here.
when you created your metafields, you had to assign them to a namespace. When you try to retrieve them with Storefront API, you have to provide this namespace, and you failed to do that.
evem if you created metafields in the admin using some App, you will not see them using Storefront API unless you turn them ON using a special flag.
So that is likely a missed step too. Read up on this and pay attention to the MetafieldStorefrontVisibility. You set the namespace and key to be visible. Meaning you likely will not be creating metafields willy nilly without careful consideration about turning each one on or off to Storefront API access.
I would extend a bit David`s answer as I cannot add comments to other answers yet.
Indeed, you have to make the metafields explicitly visible to Storefront API by running mutation MetafieldStorefrontVisibility. Here are some useful links:
How to retrieve metafield from Shopify
How to use MetafieldStorefrontVisibility
Also, I found a nice app Accentuate Custom Fields that provides UI options for making metafields visible to the Storefront API while configuring the metafields:
I'm running Magento 2.2.5 and was having trouble working out what the URL was for making API requests. For example to GET a list of countries I had seen the following syntax used:
/rest/default/V1/directory/countries
which has worked on some stores, but I was getting this error:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
I started playing around with the URL format and removed the "default" and used this instead:
/rest/V1/directory/countries
and the requests were then successful. How does one determine what the base URL to use for Magento REST API requests? I haven't been able to find this documented so far.
The syntax of Magento 2 Api is
http://<:host:>/rest/<:store_code:>/<:api_path:>
Here store_code can be any one of the "store view" of your Magento2 instance. You can get the store code in admin panel. You can use store_code to get information specific to that Store View via API. By default Magento2 installation comes with 1 website, 1 store & 1 store view (this store-view has code "default", in your case this might have changed hence you get the error).
The architecture can be understand with the help of image
Reference Image
Ref: https://docs.magento.com/m2/ce/user_guide/stores/websites-stores-views.html
When you specify store_code it checks information for that particular Store-View. If the specified store_code is not found in the database, Api returns "Specified request cannot be processed." message.
When you do not specify store_code it first finds default Website, then finds default Store for this Website & then finds default Store View Associated to this Store. And finally it returns information for this default Store-View. The association of default store & store-view can be changed from admin panel.
Reference Image
Hence the URL for API should be below in case you need store specific information. store_code can be set to all if you need information for all the stores.
http://<:host:>/rest/<:store_code:>/<:api_path:>
I'm running Magento 2.2.5 and was having trouble working out what the URL was for making API requests. For example to GET a list of countries I had seen the following syntax used:
/rest/default/V1/directory/countries
which has worked on some stores, but I was getting this error:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
I started playing around with the URL format and removed the "default" and used this instead:
/rest/V1/directory/countries
and the requests were then successful. How does one determine what the base URL to use for Magento REST API requests? I haven't been able to find this documented so far.
The syntax of Magento 2 Api is
http://<:host:>/rest/<:store_code:>/<:api_path:>
Here store_code can be any one of the "store view" of your Magento2 instance. You can get the store code in admin panel. You can use store_code to get information specific to that Store View via API. By default Magento2 installation comes with 1 website, 1 store & 1 store view (this store-view has code "default", in your case this might have changed hence you get the error).
The architecture can be understand with the help of image
Reference Image
Ref: https://docs.magento.com/m2/ce/user_guide/stores/websites-stores-views.html
When you specify store_code it checks information for that particular Store-View. If the specified store_code is not found in the database, Api returns "Specified request cannot be processed." message.
When you do not specify store_code it first finds default Website, then finds default Store for this Website & then finds default Store View Associated to this Store. And finally it returns information for this default Store-View. The association of default store & store-view can be changed from admin panel.
Reference Image
Hence the URL for API should be below in case you need store specific information. store_code can be set to all if you need information for all the stores.
http://<:host:>/rest/<:store_code:>/<:api_path:>
I am working on an integration from a software product to JD Edwards EnterpriseOne, and we would like to create items that would later be used on Sales Orders. The issue arises when attempting to create a sales order with an item that was created via the business service (web service), it requires the item to be added to a branch/plant.
There is no field on the processInventoryItem request message to set the branch plant for the newly created item -- is there any way to do this via the API and not need to custom-build a new business service which includes it?
Thank you in advance!
You could use processInventoryItemV2 to create the Item Branch after Item Master creation.
According to docs:
The processInventoryItemV2 operation is a version of the processInventoryItem web
service operation. This web service operation is used to add, update, and delete
branch plant item records along with country of origin required indicator. This version
executes the processInventoryItem (J4100003) web service operation.
I would like to highlight a relevant issue and work around implemented, which my be of help.
We have a business requirement where a manufacturing plant sends a new product to a branch plant which is not handling the product hitherto.
We worked around by creating an overnight scheduler which creates item branch record for the receiving B/P for the new item.
I am currently building an online store using magento.
After placing an order, customers automatically receive an "order confirmation". However, I would like to check first first if this order can be processed (for several reasons) and after that, send an "order acceptance" email saying that we accepted the order starting to process it.
I cant believe that magento lacks this feature.
However I also need to send several other emails:
when payment is received
when more preoducts need to be ordered
when we received the products otderd by the customer..
Does anybody have any clue, how something like this can be accomplished?
Thanks in advance!
do you know any other e-commerce platform on php that has this feature ?
You most certainly can
overwrite the saveOrder() method in Mage_Checkout_Model_Type_Onepage that calls out the sending of this e-mail
overwrite sendNewOrderEmail() method in Mage_Sales_Model_Order that defines this method
overwrite the canSendNewOrderEmail() method in Mage_Sales_Helper_Data that handles the validation if sending this mail is allowed
edit the sales_email/order/enabled config value, that is used to control the condition on helper method, to be false from admin page
After that you have to implement your own status based e-mail sending in your extension observer . You can observe the save_order_after event to do that and you can call for the same method as it is accessible from order object
Note : This is commercial software
We have used this extension by amasty called order status. It works very well. It will fire off an email from the transactional emails when a certain status has been changed.