3

I am trying to create a view for just 1 product, a gift card. We want some special front-end code to display some variable options for a gift card.

We have a gift card product type and it comes to some special options for selecting a price value. So the functionality of user-selected values is already coded.

I just want to take that product type and give it a spiffy front end without disrupting the other products.

We already have a product template, and it has some components that i need to remove. This is the path of our product view:

app/design/frontend/vendor/vendor/template/catalog/product/view.phtml

There's also a:

app/design/frontend/vendor/vendor/template/catalog/giftcard/price.phtml

(and other pages)

If someone could give me a high-level idea of steps I need to take, I would very much appreciate it.

6
  • You have definetely have a handler for giftcard product type. Under that you can call you phtml file for that particular product type and then you can write your logic or codes to that phtml file. Commented Aug 24, 2018 at 18:13
  • We have the CE version. Gift cards are not native. Some dev added this in. I surly did see an xml and some controllers, but I cannot find where the product/view.pthtml was included as a template. Any other tips?
    – dustbuster
    Commented Aug 24, 2018 at 21:05
  • What do you mean by I just want to take that product type and give it a spiffy front end without disrupting the other products. wich type of product ? Simple, Configurable... or you mean another thing ?
    – PЯINCƎ
    Commented Aug 24, 2018 at 21:20
  • Gift card type product. I really don't know the history behind it, but i went to do this project, and the gift card type was already there, but it does not come with the CE version, but it has all user variable amount settings i need. I've only been coding with Magento for a month now, I might not be able to answer all your questions. But I'll do the best i can! I am trying this now too: magento.stackexchange.com/questions/74757/…
    – dustbuster
    Commented Aug 25, 2018 at 4:11
  • I want to override the vendor/product/view.phtml And make my own view.
    – dustbuster
    Commented Aug 25, 2018 at 4:13

2 Answers 2

2

You can try the product layout update for your spiffy html. Navigate to the product page in the admin > Catalog > Manage Products > search and click on the product. Then on the product page, click on Design on the left tabs. In the Custom Layout Update

<reference name="product.info">
    <action method="setTemplate"><template>vendor/catalog/product/spiffyView.phtml</template></action>
</reference>

In the the above example, the phtml file is located in

app/design/frontend/base/default/template/vendor/catalog/product/spiffyView.phtml

where vendor is a custom module name. To simplify testing, you can create a very simple 2-liner phtml file such as

<?php // super simple product template ?>
<?php $_product = $this->getProduct(); ?>
<h1><?php echo $_product->getSku() ?></h1>
3
  • I tried this, and it didn't work for me. It would not change views.
    – dustbuster
    Commented Aug 27, 2018 at 15:12
  • I just did a test in my server and it worked for me. I edited my answer to add an example on the template path in the xml. To debug: disable your cache and turn on template path hint in admin. And if you still can't get it to work, then can you tell me your <action> xml and the complete path of your phtml file and if you have a custom module?
    – kiatng
    Commented Aug 28, 2018 at 1:37
  • Awesome. I’ll try again! My below solution worked for me, I got to keep the prices, and I was able to get rid of the default vendor product template. I’m making a snuffy UI! However I want to explore your solution to in order to find multiple ways to solve this problem. I’m sure it will come up again. Thank you!
    – dustbuster
    Commented Aug 29, 2018 at 2:02
1

I added the below line to: app/design/frontend/vendor/vendor/layout/giftcard.xml

<catalog_product_view>
    <reference name="product.info">
        <action method="setTemplate">
             <!-- NEW CODE -->
             <template>giftcard/view.phtml</template>
             <!-- END NEW CODE -->
        </action>
    </reference>
</catalog_product_view>

And removed:

<template>vendor_giftcard/catalog/price.phtml</template>

I copied page/view.phtml, removed the stuff I don't want, and created a new view.phtml template.

frontend/vendor/vendor/template/catalog/product/view.phtml is inherited by default and is not explicitly defined which was what was giving me trouble because I could not find the inclusion of it.

There is another view defined in the giftcard.xml called price.phtml and this handles the rendering of the form components for the giftcards.

Basically I need to add my new view, then add in the form components from the price.phtml view.

That's where I'm at. Understanding the basics of Magento's XML Templating system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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