Magento. Redirect to specific store view - magento

We have multi-website(5) multi-store-view(13) shop.
What we need is that only 3 store view from 1 shop are allowed to checkout. Therefore the problem is how to redirect users from other shops to the same products on specified store view.
For example user watches product on mk_nn_eng and click #Button#, after that he is redirected to mu_aa_ENG AND sees the same product, he was observing but on specified store view.
How to perform such redirect?

If it's the same item, it will have the same id. And you can link to an item by it's id using the format (assuming you have different domains set up for each view):
www.DomainForStoreViewYouWant.com/catalog/product/view/id/{{product.id}}
Where you would get the id with something like $product->getId(); depending on the product object in the file you're looking at.
So the button you mentioned would just be the above link.
Is this what you had in mind?
Update:
If it's the same domain for each view, you could add the storecode to the end: ?___store=storecode

Related

Create magento product that links to an external website

I want to add a product that is not held on my magento website. It must only show on my website. But when a customer clicks on a product it directly goes to the website that holds the product.
I want to give the URL to the product on the site. I am not sure how to do this. Please help me. Thanks.
Here are some screen shots that show what I actually want to do:
product show on my website
Customer goes to other website
The way i would suggest you is to create an attribute called external_url, a textinput field. Assign it to required attribute sets then, while adding product if that particular product will be linked to external; input that field with external url.
And while populating product in listings, check if that external_url attribute value exists or not. (for eg on template/catalog/product/list.phtml check for this value $_product->getData('external_url'))
If the value exists then, change the product link(on product list.phtml change $_product->getProductUrl() with our $_product->getData('external_url'))

magento link product to specific store view

I have 6 languages defined using store views.
i have 6 simple products - one product for each language.
I did not create those products using attributes or configurable product or so, since this is the main product in my store and i would like to promote the product in each language separately.
now, I try to link a productX to default store view X (means if someone clicks to view that product, he will move to the store view with the language of the product.
example:
- store view_EN
- store view_IT
product X_EN
product X_IT
being in store view_EN, clicking product x_IT should redirect to store view_IT/product X_IT...
is that possible with little tweaks only?
thanks!
First of all, you don't need 6 different products, one for each language. You can have the same product, and translate the text fields to all the languages (like name, description, short description, ...).
You can do that by changing the scope from the top-left dropdown on the product edit page, in admin.
Now here is how you can get a product url for a specific store. Let's say that the product id is $productId, and the store id is $storeId
$url = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId)->getProductUrl()

Redirect a product to other website

I am looking for a way to have a product on my magento store, make it visible but not purchaseable and redirect users accessing it to another page/external url.
Basically i have 6 products and would like to redirect all users who go to one of those products to another domain / external url. The product should be displayed but not be purchaseable - rather instead of add to cart link to an external url - or if possible even redirect the whole product detail page to another url...
What’d be the best way to do that?
i am trying for two days already but haven’t found the best solution yet… my programming skills aren't the best yet...
thanks!
i think what you should do is to add one new attribute for redirect url , for your six products you can specify the redirect url in that attribute , and in the list.phtml you can place a condition that if a product has value in that attribute , you can use that value in anchor tag and in else case you cam use the regular product links for other products .
i mean you can add a new attribute for a products in admin like there is other attributes eg. name, description , and in file you can fetch your new attribute like other attributes , just replace the attribute code with your and take that in condition that it will work work only if the product has the value for your new attribute
for fetching attribute in your file you can use <?php echo $_product->getAttributeName() ?>

Magento 2 stores with different product url

Here is my situation, my company buy product with no brand and sell them in its own brand.
We have 2 websites and 2 brands, some products exist in both of our brand with different name.
Example : product A of brand A named BrandA Product Premium and the same product on the other site is named BrandB Product Super.
But on both website the url-key is the same (the name of the product in the default view) so on site1 I have :
http://www.site1.com/brand-a-product-premium.html that is very good.
On site2 I have http://www.site2.com/brand-a-product-premium.html If you type in the correct url : http://www.site2.com/brand-b-product-super.html you are redirected to the bad url.
I can correct this by creating a custom url_rewrite, but there are thousands of product in this case, so I may have done something wrong and there should be a better solution for this.
May I have some help ?
Best regards.
If you are using one instance of Magento in a multistore setup you can override the url key as well as any other product attribute for each store view. Select the store view for site 2 from the dropdown on the left hand side of the edit product page and then override the required fields for that store view.
I have a multistore site where I sell some products on both but not all and using the above method gives me full control over every aspect of the same product for each store view. e.g. Custom name, description, images, categories etc. To ensure that a product is not shown on a particular site via catalog or search, I disable that product in that store view by setting visibility to none.
Do not use the URL rewrite option this will come back to haunt you!

magento show "Sign up to get notified when this product is back in stock" link for simple-associated products

How can we display the "Sign up to get notified when this product is back in stock" link for associated products of a configurable product.
Say, we have a T-Shirt (a configurable product) and we sell it in 3 sizes - Medium, Large and Xtra-Large (simple - associated products).
When the Large size goes out of stock, how can we make user subscribe for it for notification when it is back in stock.
Please note I have already set this setting in admin:
System > Configuration > Catalog > Allow Alert When Product Comes Back in Stock - Yes
I noticed that the url for this alert is like (it is for one of the simple products in my store):
http://localhost/mystore/index.php/productalert/add/stock/product_id/1/[some key]/[some key],,/
Is there any way we can call this url directly, passing the product id of our associated product in question? If so, what about those keys at the end of the url?
please guide.
thanks
I added this link beside the out-of-stock associated product:
http://localhost/mysite/index.php/productalert/add/stock/product_id/[associated_product_id]/uenc/[any_key]/
For e.g.
http://localhost/mysite/index.php/productalert/add/stock/product_id/17/uenc/MTM0MzcyMDk0Mw==/
It does my job.
Only thing is, after successfully adding the alert record, it redirects to home page, instead of same page as in normal case.
This is due to [any_key], if we could somehow encrypt current page url [the any_key] just like magento does, we can have it redirect to same page also, after successful saving of alert record.
Any ideas?
Thanks
Ok I got it finally!
The uenc key [any_key] is actually base64 encoding of current url.
So with the help of https://github.com/carlo/jquery-base64, I did:
var encodedUrl = $.base64.encode(window.location);
var redirectTo = 'http://localhost/mysite/index.php/productalert/add/stock/product_id/[associated_product_id]/uenc/' + encodedUrl + '/';
Hope this helps!
The Magento way to get the url would be:
Mage::helper('productalert')->setProduct($_product)->getSaveUrl('stock')
Magento already avails the functionality to set out of stock from admin panel, unfortunately it is limited to some instances therefore we can not set this from admin panel, either way you can do it in code as above mentioned but its a manual task and can not be done again and again with links.
So i think its better to use ready made extension in case you have specific requirement to set product stock alert functionality for customer and they can subscribe for it.
Here is the well managed extension for Magento 2 which can help you to set Product alert and sign-up / subscription functionality with many more admin manageable features.
Link to Out of stock notification extension for Magento 2 - https://www.mconnectmedia.com/out-of-stock-alert-magento2.html

Resources