In one of the Magento store, I have to restrict customers to add a product more the one time.
I checked with the cart and pass an error to the customer. But Magento does not show any message in product view page.
Mage::getSingleton('core/session')->addNotice('You have already added this product in your cart');
Check the above code, I placed it in controller file. I thought it was correct. Let me know what I missed.
I'll add an explanation later, try this:
Mage::getSingleton('catalog/session')->addNotice('You have already added this product in your cart');
Related
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'))
I add an attribute type Yes/No is_special to product.
(I want to just logged user can see special products.)
Then, I open some products and set to Yes But when I show it on front end, All is No.
I clear cache and reindex before. But It still No
Please help me guys. I am very grateful to You...!!
Thanks In Advance...!!
When attributes are added, they are added to the database and magento caches the calls to certain databases. Try deleting your cache folder in var/cache and see if that helps.
When you create a new product attribute, you have a lot of options, a few changing the loading bahavious "Show in product listing" sets the collection to load this on the category pages, "Visible on Product View Page on Front-end" loads the attribute on the product view page.
First you need to add featured/special product attribute to magento. Please refer my tutorial which explains how to add yes/no attribute.
http://www.pearlbells.co.uk/adding-custom-product-attributes-in-magento/
Then you filter the featured products using the code in phtml.
<?php
$featuredProducts = Mage::getModel('catalog/category')->load($category_id)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('featured_product', 1)
->addAttributeToFilter('status', 1);
?>
I am working in a Magento store, I want to add some information related to price near price in product view page. So I added the same near price in price.phtml file. But the problem was that added information was comes with the price in all the blocks where product price was called.
For example that information was also comes in product list page, product compare and latest products. I want to restrict it and show the information in product view page only.
Thanks,
Using the <catalog_product_view> handle, add your additional information in its own block to the catalog/product/view.phtml template right after where ever the price block content renders. Or, do the same, but add the getChildHtml call to the price block.
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
I have gone to admin -> manage product -> product information page -> related products
Then I added a product that is related, and saved.
I went to that product and refreshed the page, but nothing changed. Why not?
Also, be sure to check that the product you're trying to see in 'Related Products' is not already in your cart. Magento has a default filter applied that removes items in the cart from the related products collection.
Solution:
Login to Admin
Go to System -> Index Management
Select All checkboxes
Select 'Reindex Data' from Actions selection list
Click Submit button
Reference: Magento Up-sells Cross-sells and Related products are not showing up
Related Products appear in product info page, in the right column.
Cross Sell items appear in the shopping cart.
Upsells for this product are items that your customers would ideally buy instead of the product they’re viewing.These appear on the product info page underneath the product description.
As a result, I understand that you would show products bottom of the product info page, you should choose upsells instead of related products.
If you want related products ( which I can misunderstanding you ) do following things :
Check related product status is enabled.
Check visibility status set "Catalog" or "Catalog Search"
If everything is fine, check the inventory of related products.Stock should be greater than 0.
Last thing, related products must be include a category. Click "categories" link to check and see if the product added in a category.
Click on the "Reset Filter" button on top of the related product listing. It will list all products in table. Or you can clear cache + reindex data.
I had the same issue. After some time ago, I found that the products are not made to be visible in the visibility section, and that the products are not set to be in any website.
Hope this is the answer, and should be, because if you set up everything right there is nothing that can make problems.
Make sure the product and related product are under the same website. This isn't apparent when adding the relating products.
One possible pitfall you can run into is that you use a template without a right column. In that case you have to use unsetChild and insert to move the related product block.