Thursday, December 2, 2010

Magento: Edit in stock/out of stock messages

Hi all,

Today I've learnt another new thing on Magento. That is to edit the in stock and out of stock messages on the product page.

By default, the messages are:
Availability: In stock.
Availability: Out of stock.

The issue is, some people might want to customize or remove the stock message.
So let's begin on how to edit it:

First the files are located in:
/public_html/app/design/frontend/default/default/template/catalog/product/view/type

Important!!!
If you want to keep your changes, be sure to use a custom template instead. E.g.
/public_html/app/design/frontend/default/Your_Template_Name/template/catalog/product/view/type\

Next, just a bit of code editing. Do note that if you use all the 4 types of products in Magento you'll have to edit all 4 .phmtl files.


Now here's something a little advanced.

What if we want to do something special for certain products? Like a new hot product, but needs a special message like "Available in 2 days, check back soon!" instead of "Out of stock"?.

You can create a custom attribute to be tagged to all your product types. For example, I'll create "product_sale_status" attribute with the "normal" and "special" options.



All I have changed is:

if($_product->isSaleable()): ?>

to:

if($_product->isSaleable() && $_product->getData('product_sale_status') != 152): ?>

So on the product pages, if you wish to have a custom message, all you have to do is to select the product status to "Special" and enter your custom text in the appropriate places (I'm using Comparison Chart Link field). Note: To get the data number 152, use an php echo on the getData('product_sale_status') somewhere, preferably HTML commented.

Have fun!

Saturday, August 7, 2010

Psyched up!

A boring saturday... I'm glad I didn't spend it on sleeping till 5pm as I usually dota with David and gang till the sun almost rises.

Looking at what I've been through for the time since I broke up with Elinna, I have been working hard at improving myself. Though my determination has lapsed, I have always begun getting inspiration from animes like Naruto and Hajime No Ippo, when they self encourage and work really hard.

Rewatching Hajime No Ippo is also spurring me on to work hard on training. It was also one of the reasons why I chose boxing over other martial arts. I have to continue working hard in my life... Getting a raise (although it's two months late, can I get a reimbursement? :P ) and also most likely going to be fighting in an amateur match this December.

I want to be like Ippo, continuously training hard and being encouraged but it seems like I'm way past my age at 25. Besides Singapore doesn't have pro-boxing anyway. Still, I hope to become good at it, I need to train! I have about 4 months to train, so I'll need to work hard. WORK HARD!

Still, being lonely and single kinds of irk me. I'll work hard, for the sake of looking back and saying that I didn't waste my time. My determination has always been up and down, now it's the time to be up again!

Hope I didn't decide to be an infighter from watching Hajime No Ippo, but it doesn't feel like I am an outfighter since all the training anyway. The training time I have is also comparatively little, Ippo trains from day to night while I train for only 2 hours per session.

Let's work hard, Monday is National Day and I'll most likely be alone. Time to train!
I'll show you, you know who you are. You might have stopped caring about how I am doing since then, but I'll live my live shining. I'll make you regret betting on the wrong man.

Wednesday, July 14, 2010

A day of rest

Hi my dear blog. I have taken a day of rest, feels weird to skip training.
Usually I always have something on after work, meeting someone, training.

Now that I am free to do whatever I want from 7.30pm till sleep time, it's starting to feel unusual.

I dreamt a strange dream. It was about her, about us talking about me waiting for her. The content of the dream wasn't strange, it was somewhat a norm. Usually it's either we're talking about being back together or not being back together. Does my inner heart really want to be back with her?

I can honestly say that I will love her all my life. But the love is not strong enough to want to be back together. Emotion says yes, logic says "If you're not going to change, I'll never agree to it".

I really do love her, however her character irks me. Her refusal to change for the better, her unrelenting grip on her pride all suggests to me "it's never going to work".

However enough indulgence of fond memories and possibilities.
The main strange occurrence in the dream was that, the girl wasn't her. It wasn't her face, it was another beautiful normal looking girl. And her brother (in the dream) was my friends' brother. I was already confused in the dream. It's like watching the same drama except the actors have changed. (It) Looked really strange to me.

However, I am really looking forward to see if this girl appears in real life. She looks real, just like a normal Chinese female. I would love to woo her if I ever meet her. Though the contents of the dream was more about not being together so it kinds of foreshadows the notion.

On the other hand, I'm always playing games because there's no one to pay any attention to me. She in the past didn't pay much attention to me, did what she always wanted to. I don't think she ever noticed that I didn't touch my PSP or NDS when we went out to somewhere I wanted to, someplace I longed to. Why did I have to play the loser, why did I have to play the boyfriend who was insufficient? I guess I'll go down in official history amongst those who knew the both of us. Who gives a fuck? I do. But due to my nature, I'll just wait passively for the day karma throws her the same bullshit. I long to see that day happen.

Today, I went to help out in the warehouse. Looking at the whole thing, I actually put in effort to remain anonymous. Why do I always want to remain anonymous? I pitched in, helped by doing things fast. Did anyone notice? Who gives a fuck about Nathaniel anyway. Did you? At this time when you are reading my blog, on the 14th of July, did you give a fuck about who I am, what I did, was I an important person in your life etc etc? (I) Didn't think so.

Loneliness engulfs me. Yet I prefer to remain unnoticed. I only long to be noticed by my efforts, by my hard work, by someone who truly loves me and cares for me. As I was parking my motorcycle, I even began thinking of the notion of having a voice in my head that cared. Imagine having a sweet female voice that encourages you when you're down, chats with you just like a caring girlfriend or spouse. Other than not being able to interact physically, it's going to be like she truly knows when you are happy or when you are sad.

I just wonder if I will develop any mental symptoms or weird stuff like hearing voices or being schizophrenic. Maybe my true self will emerge as another character. Sounds like fun in a way. Like an angel or demon within yourself. I definitely hope not though. That means living an abnormal life, though I already think I am not of the norm. I grew up being a recluse and began to be more of a recluse when I get mocked by people for moving out of the shell. That happened in primary school. Was it a trauma? Yes definitely.

This seems like a long story that I am typing today. Why it's only 7.44pm. I'm sitting in my room and not doing a thing except feeling hungry and sleepy. I'm pathetic. I began to doubt my own faith, Christianity and God in some ways. I'm going through a terrible phase in my life.

The pain is starting to flow back. Whenever I'm tired or in a really stressed situation, I start getting emotional and think of all the hurts and pains of the previous relationship. The biggest question I will always be asking is "Why?". "Why do I have to bear this burden while you continue living a life that looks greener on the other side?".

"I put in so much into this relationship and you threw in all away in less than 3 months. 8 years thrown away in 3 months. All you could say that 'It just happened' and 'You shouldn't have agreed to the breakup.'."

Do I deserve this? And do you deserve your happiness? It's true, the one that puts more into the relationship is hurt more than the other.

I hope you suffer an emotional pain as excruciating and torturous as you have gave me. Though I doubt that you have the mental fortitude to bear it just as I have.

Please, let me see it with my own eyes when the day comes.

Saturday, July 10, 2010

Weekends and my dreary existence

Another dreary weekend.
I feel non-existent, like I'm forgotten by the world.
Today is only the 10th. I'm not sure how I can survive until the end of August.

Also, in truth I'm not ready for another relationship. I just want someone to understand me, to hold me, to spend time with me.

I'm not ready for another girl, I haven't shook off the fear of another break up yet.
It's like, what if, I enter another relationship only to have to break up again? It's the equivalent of strapping a time bomb to my fragile heart. It's already wounded, need I place it in the line of danger again?

Existence seems to be near meaningless for me. Relax my dear blog, suicide is never an option to me. I intend to see through this life, no matter how meaningless it feels right now. I love food, I love singing, I love games (though it's a tad of waste of time), I love girls ;P (my partner I mean, I'm not exactly a Casanova, though I'm single now).

I look up to the sky at times and wonder, how little and insignificant am I. Even if I were to die right now (for some reason), would friends mourn me? I know they would. The real question is what would the difference be for me to be alive or dead. How would I affect their lives after my death? I wouldn't be missed really, due to my reclusive nature. Friends usually know me as someone whom can be depended on but not when you're looking for someone to chat with, someone to fellowship with or to go out with.

In that sense I am non-existent until a friend remembers me because of old times sake or if they need help in which I have the expertise. Does it matter even if I accomplish something great in my life? If it isn't great enough to impact others why does it matter? I feel dead though alive, feeding only the mortal shell that strives to live till tomorrow and then it goes again in a cycle.

I hope I have something good or positive to blog about, though I doubt it. Even progress seems to wane in meaning, fade to black and white in the face and presence of loneliness.

Oh my empty soul, what ends do you seek? What purpose drives your birth and journey to the end? Tell me, Nathaniel, tell me.

Friday, July 9, 2010

Been's a while

It has been a while since I've last posted something.

I have decided to return, since I don't really like the idea of posting everything on Facebook or somewhere similar.

I would just like to pen my thoughts, yet too lazy to write in a diary.
Seems like this personal blog would be a good place to start.

Have joined a boxing gym since I returned from reservist.
You can check it out at singapore-boxing.com.

I noticed my frame getting slightly bigger, maybe due to the shoulders, since I have to train my shoulders for punching stamina/power. It has been a month since.

The coach shocked me by asking if I was ready for my next fight. Most likely there will be one in December.

I'm not really a fan of hurting people, though the thought of adrenaline pumping in a fight excites me.

I've improved my running stamina as well (for a 2.4km run after 30 minutes of warm up, skipping mainly), from 14 minutes to 10 minutes 43 seconds. I'm looking to hit the 9 minute mark just like my peak.

I'm reserving my thoughts and refraining from thinking that I'll be faster without the warm up.

If I can hit the 9 minute mark with the warm up exercises, then even without I should manage.

Still, I'm currently improving on my punching form. Next would be weaving stamina and punching stamina.

I only have about 5 months until my debut novice match.

Here's how I have improved over the month:
Running stamina
Forearm and finger strength (My injured pinky was hurting in the first few sessions, now no longer)
Footwork

Every training seems to help me in releasing some stress and anger and I've begun to foster an attachment to the gym. Mostly I have been taking advice from Coach Dick, Coach Kadir seems to be pretty busy most of the time.

7-8 hours of sleep doesn't seem to be enough, I guess it's just my body complaining. It should get better in a month or two after my stamina really climbs.

Saw a huge rainbow as well, wasn't really excited though I was hoping to have someone by my side to look at it with.

Tried to know a girl recently as well but she's attached, so why did Adriel introduce her in the first place :|

Got pretty upset when the old memories come back. What did I do to deserve this? I'm hoping and still waiting for justice to be done.

Gotten in pretty bad financial status as well, used up my advanced salary (because I thought it to be my commission) and commission has ceased since February.

Oh well... sucking it up and pushing on.

Hope to be able to improve myself further, like getting a nice body and posting videos of me singing and stuff. Not enough motivation and confidence for that yet.

See you soon blog.

Thursday, June 3, 2010

How to set the decimal points or decimals in Magento

I was screwing around with Magento to attempt on getting the decimal places to work.

Searching online, I found a solution: to edit a particular line of code in /public_html/lib/Zend/Currency.php.

All you have to do is to change line 62, "'precision' => 2" to "'precision' => 0" or to a number that you want. However this solution is purely hard-coded.



What if you have multiple websites that uses the same Magento system?

Here's the solution to it, I have created some code to assign the precision value:
*** WARNING: Perform a backup of Currency.php in the event something goes wrong! ***

- Firstly, open up /public_html/lib/Zend/Currency.php

-Add this line of code after around line 90, you should see several similar lines like:
$this->_options

Code to add
$this->_options['precision'] = self::getPrecision($currency, $this->_locale);

-Next, just add in the next block of code within the class itself. If you're not sure where to put it, you can just paste it just before the lines of code above
public function toCurrency

Here's the code:

public function getPrecision($currency = null, $locale = null)
{
if (($currency === null) and ($locale === null)) {
return $this->_options['symbol'];
}

$params = self::_checkParams($currency, $locale);

//get the precision
$format = Zend_Locale_Data::getContent($locale, 'currencynumber');

iconv_set_encoding('internal_encoding', 'UTF-8');
if (iconv_strpos($format, ';')) {
$format = iconv_substr($format, 0, iconv_strpos($format, ';'));
}

//knowing the number of digits after the decimal point
if (iconv_strpos($format, '.') == null) {
$precision = 0;
} else {
$precision = iconv_strlen($format)- 1 - iconv_strpos($format, '.');
}

return $precision;
}

- Next, save your Currency.php file and upload it back to /public_html/lib/Zend
- Lastly, edit the appropriate xml files to have the decimals set.

For example, here's the code for en_AU.xml which I am currently testing on.
Note that I have changed the angle brackets to square brackets for documentation purposes on a blog.

[?xml version="1.0" encoding="UTF-8" ?]
[!DOCTYPE ldml SYSTEM "http://www.unicode.org/cldr/dtd/1.5/ldml.dtd"]
[ldml]
[identity]
[version number="$Revision: 1.46 $"/]
[generation date="$Date: 2007/08/21 16:11:36 $"/]
[language type="en"/]
[territory type="AU"/]
[/identity]
[numbers]
[currencyFormats]
[currencyFormatLength]
[currencyFormat]
[pattern]¤#,##0.00[/pattern]
[/currencyFormat]
[/currencyFormatLength]
[/currencyFormats]
[/numbers]
[/ldml]

Friday, February 12, 2010

Chords: 陈伟联 - 我只在乎你

Youtube link:
http://www.youtube.com/watch?v=zdM7hBvewSE&feature=related

Intro
C Em Dm G

C Em Am Em
如果沒有遇見你 我將會是在那裡
F Em Dm G
日子過得怎麼樣 人生是否要珍惜
C G Am Em
也許認識某一人 過著平凡的日子
F C Dm G
不知道會不會 也有愛情甜如蜜

C Am
任時光匆匆流去 我只在乎你
C Am
心甘情願感染你的氣息
F Em Am
人生幾何 能夠得到知己
Dm G E
失去生命的力量也不可惜

Am Am/G# Am/G D/F#
所以我求求你 別讓我離開你
C Em Am Dm G C
除了你我不能感到一絲絲情意

C Em Am Em
如果有那麼一天 你說即將要離去
F Em Dm G
我會迷失我自己 走入無邊人海裡
C G Am Em
不要什麼諾言 只要天天在一起
F C Dm G
我不能只依靠 片片回憶活下去

Thursday, January 28, 2010

Wednesday, January 20, 2010

Moving on...

Hey blog...

Haven't been posting on you... No one reads anyway... I hope to be reading you in the future when my memory goes bad...

Anyway... I have been moving on with life, everything is moving on other than I'm romantically zero. Single-hood and no target in sight. Not that I'm actively looking, I'm not in the mood for it anyway. I don't move on as fast as Ms. Toh. That's less than 3 months.

I'm quite tempted to see her latest updates on Facebook... Very very tempted but I shall not. It brings back the pain in a way... She dropped me for financial reasons, not that she's materialistic but she has a bad shadow or trauma on poverty. Can't say I blame her but she's not being sensible or having a common sense.

When she wasn't doing well in her insurance I had to lend her cash occasionally. I even paid for most of her laptop and then she almost wanted to buy a car. Imagine the financial burden and outlook at that point of her insurance career. Did I drop her for financial reasons? Definitely not...

Of course it almost evened out later when I was still looking for a job in the economic depression.

Looking at my point in life right now, I'm much better off. Financially, materialistically, physically. Romantically zero. Not that I'm looking for a relationship but it's like I've gained a lot more but lost happiness. Not that there will be much happiness if we didn't break up, but I've definitely lost happiness.

Time to move on, I have a schedule meet, improvements to work on. I just need to move on with motivation and positivity. But the human, the carnal and emotional me wishes for Ms. Toh to suffer once what she has made me suffer through.

Evil? Vengeance? Hell hath no fury like a human betrayed and scorned. Of course that is bullshit, I'm not that evil, I just want her to stop standing on her tower of pride. That tower of pride has stood between us since a long time ago. And my only wish is to see the proud humbled.

God grant me this wish.

Thursday, January 7, 2010

Sleeping woes

Been taking power naps in exchange for my sleeplessness in the day...

Of course I do my work... I come in early to do work before I touch my power naps.

In any case, even naps are kind of screwed up... I'll fall asleep inconsistently.
It'll be like a semi-conscious state where you are resting able to perceive auditory information yet rest. Yet it is not a complete rest...

Anyway I had a dream of her again. In this dream I was in a car with her, where she needed my help to do some mundane chore (pick up her auntie from the airport) even though we have broken up and stuff. So I sort of confronted her and asked her many questions that I would have asked if she were to seek me out for a talk.

Fucking dream felt real and waking up just leaves me confused and tired.

Fitness and Hunkness in 7 months

I've 'concocted'/drew up a 7 month plan for my bodybuilding journey, set to end by July 2010.

Originally slated to end by Dec 18 2010, I have actually calculated it to end by July 2010 because of IPPT, I will have to do the actual training.

For example, currently I'm doing jump ropes instead of running. When my training regime ends, I will be doing the running and chin ups etc instead of weight training and jump ropes etc.

Most likely I will have passed IPPT because there is an ICT in April. No matter, my training is for CDO gold so press on!!!

Right now all I need is to take a before/after photo... Need to get a nice 'before' photo haha...

Wednesday, January 6, 2010

To 2010 and beyond!

Hi my dear blog.

It's the first post of 2010...
Many things happened last year... and many more will happen this year. Good or bad, it will come.

I am currently heading on to complete Project Hunk in time for Dec 18 2010 and some other stuff...

I went back to church, through a friend who was there for me at the right time...

I'm also silently waiting for the time of reprisal, a time of revenge, though it's not right to be doing that, but I have every right to do so after being thrown away and left to die emotionally. I want YOU to feel that pain. Until then, like my friend Serene says, I should live my life better and improve it to the point where Ms Toh will regret her decision, as a form of revenge. Or maybe I misunderstood what Serene has said but I'm partially blinded by revenge.

Woops a long line on revenge... Let's not lose focus on my own personal life.

Exercise and work, let's go. Keep the money rolling in, even if it's little by little... I still have the installments on Kaelyn to finish.