How to create SEO urls in Shopware 6 - seo

I have a shop running on Shopware 6. The data is being migrated into that shop from Magento 1.8. In magento shop one can assign multiple url's to a product. So that a productA can be accessed via shop.domain/productA, shop.domain/categoryA/productA, shop.domain/categoryA/bategoryB/productA.
In shopware after the product got imported it only has one link to it - shop.domain/product-a (shopware parses the names into url keys differently than magento in case of some more crazy product names that I have).
I need help in having the product have the same links it had in magento - shop.domain/productA, shop.domain/categoryA/productA, shop.domain/categoryA/bategoryB/productA. How can I do that?
If this is not possible then how at least can I assign to the product a custom url-key so that it it the same as in magento?
I have found that the product entity in Shopware has a relation to seo_url entity and I have been trying to push different combinations to that endpoint via API, for example:
'foreignKey' => $shopwareProducts[0]->id,
'salesChannelId' => $germanySalesChannelId,
'routeName' => 'frontend.navigation.page',
'pathInfo' => 'productA',
'seoPathInfo' => 'seoPathInfoTest'.$shopwareProducts[0]->id
and it seems to go in without errors, but I have no idea how to make it work on the storefront side (meaning th elink gives me 404). There is a Settings->SEO page where URL seems to be configured but I do not know exactly how to built the snippet to work (tried variations of {% for part in product.seoUrls %}{{ part.seoPathInfo|lower }}/{% endfor %}).
The other thing I tried to use is product's Canonical URL settings and enter some paths in SEO path field but it always gets me this error:
errors [ {…} ]
0 Object { status: "404", code: "FRAMEWORK__SEO_URL_ROUTE_NOT_FOUND", title: "Not Found", … }
status "404"
code "FRAMEWORK__SEO_URL_ROUTE_NOT_FOUND"
title "Not Found"
detail "seo url route\"\" not found."
meta Object { parameters: {…} }
parameters Object { routeName: "" }
routeName ""
I am quite new to shopware and all this is very confusing to me :/ Can anyone help please? Shopware documentation is completely unhelpful in this regard. Oh and I need to use the API because I have about 1600 products to import, so cannot do it by hand. I can easily extract all url keys from magento and if I will knoe how to push them into shopware (seo_url?) then I will be saved.
Same for categories - is there a way to have them use a different url key?
Also is it possible to assign many url's to a product, or can there be only one?
I do not have the cache enabled yet.

All you have to do after all that is to go and refresh your indexes. After that clear the cache.
Settings -> System -> Caches & Indexes
After that the seo urls will be generated. You will have to wait a bit though

Related

Shopware 6 Store-API set newsletter recipient tags

I'm trying to add a newsletter recipient through store-api, which works. But when I try to add a tag inside the request, it fails. The documentation states that it is possible to add a tag as a string to the request, see here
My request looks like the following:
POST /store-api/newsletter/subscribe
{"option":"subscribe","email":"email#email.com","storefrontUrl":"http://myhost.test","tags":"men"}
I also tried to make the tags value an array, but this doesn't work either...
So my question is: how do I add a tag to the newsletter recipient through the store api?
As of Version 6.4.3.0 this seems not possible.
I tried the same request as you, as well as
"tags":["men"]
and
"tags":["uuidOfExistingTagGoesHere"]
all does not work.
Also the doc block for tags is wrong (it says "zip code" instead of a useful description).
In addition I tried to assign existing tags - this is what works via the admin API:
"tags": [
{
"id": "80df380188364f3c9bbaaa4d6b993dbd"
},
{
"id": "108428f0a37c4d11a66976adc5337c23"
}
]
Which still returns
"code": "FRAMEWORK__WRITE_MALFORMED_INPUT",
"title": "Bad Request",
"detail": "Expected data to be array.",
Also looking at the code there currently seems no handling of the tags. As far as I understand it, the tags would needed to be created on the fly
A possible fix would be the following code:
if (isset($data['tags']) { // inserted that lines
$data['tags'] = $data['tags']->all();
} // end inserted lines
$data = $this->completeData($data, $context);
Using that line, the last mentioned request works (you could then use the IDs of existing newsletter recipient tags).
Of course in this case the API docs have to be adapted.
TL;DR
In my opinion, this seems a flaw in the current Store API implementation.
I would suggest to create an issue on the Shopware 6 issue tracker.

Bigcommerce API Add Images

Using the legacy API in bigcommerce, trying to add a product image without success. I have done this before but it seems to not work now.
The API documentation says that there is a function to 'create a product image', however it says that the field 'product_id' is read only and any request will be rejected if it is included. If that is true and not a typo, how are you supposed to create a product image against a product?
Don't add product ID to the parameters, add it to the url. So if you want to add images to product 12345, make a post to
'/products/12345/images'
of the image data
{ 'sort_order': 1, 'image_file': 'http://blah.jpg' }

How to get the most popular page under a section using Site Catalyst (Omniture)?

I want to use the site catalyst api to get the most popular page (page that has maximum pageviews) under a given site-section? Let me explain better with an example.
My website has multiple channels (News/Journals/Books/Events etc). Each of the channel has many pages under it. I want a api call that will get the most popular news page or Journals page or Books page etc.
I am passing data to sitecatalyst like this..
s.pageName = o_title;
s.channel = o_structure
s.prop1 = o_iden
where o_title has the page title of a newspage or a journalpage etc..
o_structure refers to either "News" or "Journals" or "Books" etc.
Currently I am able to only get the most popular page on the entire site. I would appreciate if someone can help me find the most popular page per section.
Thanks,
Rag
I assume that you already know the basics of using the Omniture API, how to queue up a report and look for status and get it etc... here is a basic REST data string to get site sections (s.channel) broken down by page names (s.pageName) with page views as metric. You will use the Report.QueueRanked API method, and you need to specify the rsid(s) to get the data from and the date ranges.
{
"reportDescription": {
"reportSuiteID":"RSID",
"dateFrom":"YYYY-MM-DD",
"dateTo":"YYYY-MM-DD",
"metrics":[
{
"id":"pageViews"
}
],
"sortBy":"pageViews",
"elements":[
{
"id":"siteSection"
},
{
"id":"page"
}
]
}
}

In a RESTful application, how do we differentiate between an "action" and an HTTP verb (GET, POST, PUT, DELETE)?

In a RESTful application, how do we differentiate between an "action" and an HTTP verb (GET, POST, PUT, DELETE)?
For example, as I understand it, a GET request to the resource /products should return a list of all products. A POST request to /products should create a new product. How, then, does the user request the original form which is used to create the product? My initial response would have been a GET request to the same URI, but as mentioned above, that should return a list of all products - not a blank form for creating a product.
In most frameworks I've researched, this problem is solved by making the "action" part of the URI. For example, a POST request to /products/create would create a new product, whereas a GET request to /products/create would give the blank form for creating a product. To get a list of all products would be a GET request to either /products or /products/get, /products/read, etc. depending on the framework in question. This approach resolves the ambiguity above, but it conflicts with what I've read about traditional REST design.
IMHO, the best option is to make the request method a part of controller's action.
Lets say you are accessing http://who.cares/product/42 or http://who.cares/product/42/specification . This query to webserver would translate as Product controller. The actions name should be created by combining request method and command:
DELETE "http://who.cares/product/42"
controller: "Product",
action: "deleteProduct()"
GET "http://who.cares/product/42/details"
controller: "Product",
action: "getDetails()"
POST "http://who.cares/product/42/review"
controller: "Product",
action: "postReview()"
GET "http://who.cares/products/
controller: "Products",
action: "getProducts()"
POST "http://who.cares/products/
controller: "Products",
action: "postProducts()"
here is example like it Rails does
REST request path | action name | Description
---------------------|-------------------|-------------
GET /profile/new | new | Render a form for creating the profile
POST /profile | create | Create a the profile from the received data
GET /profile | show | Render a the profile
GET /profile/edit | edit | Render a form for editing the profile
PUT /profile | update | Update the profile based on the received data
DELETE /profile | destroy | Destroy the profile
I don't see any conflict , Idea is that
urls are human readable and you can introduce new URIs to show different representations of the same resource. (like profile/1/edit and profile/1)
/profile/new - address of profile that is empty (like profile/1, profile/2 .. etc in show method)
But if you want you can suggest that profile/1/edit is some kind of different - nested resource of profile/1/ resource, but I like to thing that it's just other representation of profile/1/ resource =)
Also is good idea to use plural and singular URI when you working with many resources or with one, example
/profile/1.html - gives you 1 resource
/profiles.html - gives you list of profiles

Magento API creates simple product correct -> but afterwards tells "101 Product not exists"

I try to add some pictures to a simple product, which was created (without error) by the API. The product is shown in frontend its functional with all wanted attributes. But if I check afterwards
$client->call($sessionId, 'product.info', '123456');
I get Soap Error: "101: Product doesn't exists". But its definitivly reachable over back- and frontend. (Cache cleared, Index refreshed)
Same issue, when I try to add media informations. On Confugurable Products the error don't show up and the pictures are added whithout any problems.
Maybe I messed something up with the attributes or the attribut sets... I don't know, where to watch first.
I'm at my php’s end!
Using Magento 1.6.0.0
Thank your for clarify me.
Best regards.
Since the ame API function ("product.info" in this case) receive as a parameter both SKU and ID, there is a problem if your are looking for SKU's which is numeric values.
To avoid this problem, we always adding space to the end of SKU before sending it to the API. For example, if your SKU is "123456" you should send "123456 " to the API.
Have you tried this call with your product id instead of the sku? I had some problems in the past with product calls and the sku.
I've installed 2 magentos and we always use numeric SKUs and I've always had this problem.
I've solved it by modifying the file:
app/code/core/Mage/Catalog/Model/Api/Resource.php
About line 122 that reads:
$product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);
I've changed it to:
$product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), 'sku');
This way the function always expects an SKU.