0

First, I'll say that I am very new to Magento and realize I may have taken too big of a project. That being said, I have too much time and money invested to turn back now. LOL

I am using CE 1.9. I want to have a daily special that changes at midnight and is displayed in a sidebar block. I've looked at several extensions and found one I thought would work, but it's not working as advertised and the developer is balking at refunding. So I'm leary of purchasing others.

I can use import/export to set special prices and dates, but I don't know how to display JUST that product in a widget. It will have a unique price.

Is there a beginner/newbie friendly way of doing this?

Thanks!

0

There are many possible way to achieve this. Here I am providing you a clean method that you can rely on.

1. Create an attribute that makes your product special

Yes. The first step is to create an attribute that makes a particular product "special". You can do this by Catalog > Manage Attributes. This steps involves creation of an attribute, assign it with an attribute set, then edit your product through the backend and make that attribute value to yes.

Here I assume the attribute code that your are using is my_special_product.

2. Do some Layout update for home page.

Now it is the time create a space to show our special product. For this we need to do a layout update. Add this code inside home page that you are using.

<reference name="right">
    <block type="core/template" name="special.product.block" template="special/product/right.phtml" />
</reference>

As you can see, this layout update inject a custom block with name special.product.block into the right bar section of home page.

3. Define the template file for special product

Now we have added a space for our special product on the right section of home page. Now we need to filter our special product and display it in the right section. For this we need to define our template.

So create a file in the following location.

File : app\design\frontend\<your_package>\<your_theme>\template\special/product/right.phtml

<?php

$specialProduct = Mage::getModel('catalog/product')->getCollection()
                      ->addAttributeToFilter('my_special_product', array('eq' => 'yes'))
                      //you can put more filters here as your need
                      ->load()
                      ->getFirstItem();
?>
<div><?php echo $this->__($specialProduct->getName()); ?></div>
<?php // do anything with $specialProduct ?>

EDIT

If you need to show this product in every page, then you can do layout update through layout xml file. For this, follow this step.

File : app\design\frontend\<package>\<theme>\layout\local.xml

<layout>
    <default>
        <reference name="right">
              <block type="core/template" name="special.product.block" template="special/product/right.phtml" />
        </reference>
    <default>
</layout>

If you are using this code, then you can skip the second step. This step replaces second step. local.xml is a special layout XML file, which will process after processing all other layout XML files. So use this layout file wisely :).

I hope that will give you some idea to start with. Now wish you a "happy coding"

6
  • Thank you for taking the time to post all of this. Looks scary, but I'm going to give it a try! :) – Tracy Sep 18 '14 at 14:58
  • I'm not sure what I'm doing wrong, but it's not working. Here is what I have done: Created the attribute called 'daily_special' and added it to an attribute set that I am currently using for a large number of my products. I chose a random product and marked the attribute 'yes'. Copy/pasted the above code, created a file and uploaded it (/public_html/app/design/frontend/ultimo/default/special/product/right.pthml) – Tracy Sep 18 '14 at 22:11
  • In the copy/pasted file, I did change the attribute name to 'daily_special'. I added the reference code to the Layout Design tab of my CMS block that is my home page. Nothing shows up. I did turn on paths and I do see where the block is supposed to be, but no product is showing. I added '<?php echo "meow"; ?>' to the right.phtml just to see if anything would output. Again nothing shows. What am I missing? Thank you again for your assistance. – Tracy Sep 18 '14 at 22:14
  • you are supposed to be use that code in CMS > Pages and not in CMS > Block. I have tried <?php echo $this->__('can't u see me ?'); ?> code insde that template and gives me output. You need to make sure, you are loading the cms page where you included the code. Most importantly, you need clear all cache. Disable cache from admin side. Except this, i can't see any mistakes in your code. I will make a small update. So that you can try it out and let me know the result – Rajeev K Tomy Sep 19 '14 at 1:07
  • I had to put the file in base theme folder instead of my theme. Also, I put the special directory in /template directory. It works now. – Tracy Sep 19 '14 at 16:31

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.