-
-
Notifications
You must be signed in to change notification settings - Fork 312
Redirects
Joshua Harms edited this page Dec 20, 2023
·
1 revision
A Redirect
lets you create URL redirects on a Shopify store. When a store visitor navigates to a redirect's Path
, they'll be redirected to the redirect's Target
.
var service = new RedirectService(myShopifyUrl, shopAccessToken);
var redirect = new Redirect()
{
Path = "/ipod",
Target = "https://apple.com/ipod"
}
redirect = await service.CreateAsync(redirect);
var service = new RedirectService(myShopifyUrl, shopAccessToken);
var redirect = await service.GetAsync(redirectId);
var service = new RedirectService(myShopifyUrl, shopAccessToken);
var redirect = await service.UpdateAsync(redirectId, new Redirect()
{
Target = "https://apple.com/ipad",
Path = "/ipad"
});
var service = new RedirectService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(redirectId);
var service = new RedirectService(myShopifyUrl, shopAccessToken);
int redirectCount = await service.CountAsync();
//Optionally filter the count to only those redirects with a specific path or target
int filteredRedirectCount = await service.CountAsync(path: "/ipod", target: "https://apple.com/ipod/");
var service = new RedirectService(myShopifyUrl, shopAccessToken);
var redirects = await service.ListAsync();
//Optionally filter the list to only those redirects with a specific path or target
var filteredRedirects = await service.ListAsync(new RedirectListOptions() {
Path = "/ipod",
Target = "https://apple.com/ipod"
});