0

I tried to research online but didn't really find an answer. I am totally new in coding and it'll be really helpful if you can make the answer in detail.

  • I did not understand your question. Where do you want to show this button? – Vikas Verma Jul 26 '17 at 16:06
  • When click this button , do you want to redirect to amazon where you have add this product ? – Pawan Jul 26 '17 at 17:11
  • Vikas, I'd like to show the button on product page so that customer can choose to checkout at my website or buy it at amazon. And Pawan, yes a redirect to my product page on Amazon will be perfect! Thanks for the response guys. – Jeff Z Jul 27 '17 at 3:56
0

Could you add an attribute to your products for 'Amazon URL' and then add this to your product page template?

In your back-end navigate catalog/attributes/manage attributes then create the attribute, and then add it to your products' attribute sets in catalog/attributes/attributesets

from there, create a copy of catalog/product/view.phtml in your theme design folder which includes the following button:

<a class="button" href="<?php echo $this->getProduct()->getAmazonUrl(); ?>"> Buy from Amazon</a>

This will add that link to your product page, and you could place it wherever you wanted.

  • Nick, thank you very much for your response. I've tried your guide and add a new attribute to my attribute sets. After that I couldn't locate the catralog/product/view.phtml file on my server. I am using WinSCP to connect my server and looked up all files and still didn't find it. Is there anything I done wrong? thanks again! – Jeff Z Jul 27 '17 at 4:40
  • Hey Jeff, if you're new to Magento it can be a steep learning curve. How the structure is set up to find the view file is {magento root}/app/design/frontend/{current theme}/{skin}/catalog/product/view.phtml In your case, you might find that basic view.phtml file in your 'base' theme and you'd make an identical file path in your desired theme this link has more info devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/… – Nick P Jul 28 '17 at 19:38
  • Thanks Nick, I have added an attribute to my product however it display on my product info section and I don't quite understand what you mean that I could place the link wherever I want... Also the closest files I could find is magento2/app/design/frontend/t90/magento_catelog/templates/product/list.phtml or magento2/app/design/frontend/t90/magento_catelog/layout/catelog_product_view.xml I have tried to add your code in both files but nothing seems to change :( I might keep doing research, thank you very much for your kindness, it was helpful and I feel like I'm getting closer to the solution – Jeff Z Jul 30 '17 at 5:50
  • Hey Jeff, as far as the attribute showing on your product info section, there is a setting on the attribute, in the back end, that makes the attribute display there - you can hide it! The trickier part you're faced with is finding the phtml file that you can put the link on, have faith, you are almost there!! – Nick P Jul 31 '17 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.