Showing posts with label english. Show all posts
Showing posts with label english. Show all posts

Friday, October 21, 2011

Magento's isInStock ... yeah right ;(

OK, now I'm confused (more than usual ;)) ... why on the earth they did this (maybe they just hate me ;))

While I was looking for the name of event fired when product is in stock status is checked I found this "gem" of the code in Mage_Catalog_Model_Product:

    public function isInStock()
    {
        return $this->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
    }

WTF?!?

So ... $product->isInStock() will always return TRUE if product is enabled ... WHAT!?! Who put (or left) that stupidity in the code!???

And real stock check is:

    /**
     * Check is product available for sale
     *
     * @return bool
     */
    public function isSalable()
    {
        Mage::dispatchEvent('catalog_product_is_salable_before', array(
            'product'   => $this
        ));

        $salable = $this->isAvailable();

        $object = new Varien_Object(array(
            'product'    => $this,
            'is_salable' => $salable
        ));
        Mage::dispatchEvent('catalog_product_is_salable_after', array(
            'product'   => $this,
            'salable'   => $object
        ));
        return $object->getIsSalable();
    }

And yeah, there is also isSaleable (typo?) alias ... Huh!?

Whenever I look into Magento core code I get ton's of the possible great posts for the The Daily WTF! :D

In the end one can hope that they (and no one else) did not used isInStock method for checking if product is in stock!!!!

Sunday, October 9, 2011

Development tools

Setting up (yet another) MacBook before trip to client I got to re-visit all of my tools I use to work on Magento (and almost all other programing stuff I'm working on) so I decided to (finally) make I list of stuff I always install/use.

OS: OS X

It Just Works.

After years of maintaing all of the popular OSes one learns to appreciate that simple and yet powerful quote.

I do use Linux on my PC but I still can't find good replacements for tools I'm using on OS X. I even have Windows lying around, but only for gaming, development on Windows is ... (let's not go here ;))

Editor: TextMate

After a years of searching I still can't find anything better -- simple, extendable, fast ... (i do use Geany on Linux too). With the right collection of bundles it's simply unbeatable (I did use vim, emacsen, ... but let's not start editor wars all over again :))

And as icing on the cake 2.0 is just around the corner!

Story about using TextMate would not be complete without some of the great bundles I'm using with it

GetBundle

(some links are dead so I'm linking on TextMate blog entry instead)

Easiest way to get one of the zillion bundles for the TextMate

Using it it is easy to get Python, PHP, Validate On Save, Git related and all other bundles which make development much more easier.

Full screen on Lion

I'm the first one when complaining about people using full screen windows on modern monitors, but ... on 13" MacBook new Lion's fullscreen mode begins to shine, especially coupled with multitouch gestures.

Missing Drawer

This is a great companion for the full screen bundle as TextMate's full screen mode is missing project driver without it. Also adds neat little button for opening terminal window directly from within project drawer.

VCS: GIT

Enough said. No developer should work without some VCS in place ... never. GIT is my favorite almost from the moment I first saw it. Distributed VCS FTW!

Source Tree

Source Tree is nice GIT/HG GUI wrapper, and it's free :)

Terminal.app

I do spend rest of my development time in it (when I do not write code in editor) and anyone trying to develop on Win knows why it's on the list.

FTP/SFTP/... client: Cyberduck

Simply the best client on OSX and Win.

Browsers: All of them

Enough said ... someone please, please, please ... kill (or if that's possible fix) that IE ... please!!!!! And while at it ... hit Flash for me ... hard!

Magento

Pffff ... well ... ummm ...

I don't want to fill this entry with lot of the nasty words ... It's a shame that their software designs skills are not good as their marketing skills.

Hopefully 2.0 team will learn how to design something which is not ...

PHP

PHP language design is ... lacking to say it mildly ...

Python

OS X of the programing languages -- It Just Works!


Ouch, this is turning in real big wall of text ... better to wrap it up

to be continued...

Saturday, May 8, 2010

WinMerge

Another nice one in toolkit great diff tool nicely integrated in rclick menu.

Wednesday, May 5, 2010

WinSCP

Main thing which I was missing on filezilla was need to confirm upload when editing remote files (damn I miss Cyberduck)

WinSCP has it and on plus side it can be made to look just like TotalCommander :D

KeePass Password Safe

One of small tool jewels for anyone who needs to keep tracks of lot's of account/passwords. It keeps them in AES/Twofish encrypted file, can auto-type username/password in most of dialogs/shells and also can "drag" that trough clipboard to add even more protection from keyloggers. Did I mention that it can organize all needed passwords very nicely :)

As password file is encrypted is fairly safe to keep backup of it on dropbox for example - no more hunting for lost passwords :)

And it's Open Source :)

Tuesday, April 13, 2010

My magento .gitignore

Based on Git ignore (.gitignore) file for Magento project I started working on my version of it. I published it as gist on GitHub so it will be easier to maintain. Here it is:


Monday, April 12, 2010

SubSwitch

SubSwitch is a great Thunderbird addon if you have need to organize your email, it help adding meaningful subject lines to outgoing mails just like I used with various mailing lists (like [Foo]) so latter filtering will be very easy.

Only problem I did found is that saving preferences do not work on *NIX version of Thunderbird 3, probably some permission problems.


Windows symlinking

One of thing I do missing working on Windows is possibility of symlinking as I used to them on various *NIXen and OS X and as I'm lately giving Win7 a try (surprisingly pretty good for a change) I was delighted when I found that from Windows Vista NTFS got real symlinks (wikipedia) too :)

Thursday, April 8, 2010

Switch to HTML mode in Thunderbird

I was looking for this for a long time: Thunderbird compose HTML

In short: Shift + new mail = write new mail in HTML mode

Off-course I do presume that one is using Plain Text mode as default as all should :)

Wednesday, April 7, 2010

Ditz - issue tracker for me

Last few days I was (also) hunting for useful, small, unobtrusive and preferably distributed or at least hosted multi component - multi project issue tracker. And sure there are a ton's of them but ... I don't need all that complexity (yet) that first-class trackers like Trac, Mantis and other's offer ... I just need to track my issues/tasks locally and maybe share them with a few others ...

An there Ditz shines! in the true UNIX philosophy -- do just one thing, but do it right -- he uses plain text files in directory to store task, simple shell commands to manipulate with them and on top of that it can generate very nice HTML issue page(s) so you can use (and send) just like some type of progress report. I really can't find any faster and simpler solution for task management than:

$ ditz add
Title: find fooo
[snip help mesage]
Find baz's partner
.

For the rest of command syntax see Ditz site

Hehe mail foo@bar.baz flashback :)

And, that's it task is in bugs directory (can be configured) as just plain YAML file. One can put that dir with sorce and under some DVCS and ... instant distributed issue tracking :D

And there is more .... all that functionality is just a few K of ruby scripts which will run on anything you can get ruby to work :) -- even on Windows ;)

Now, if I can manage to find me a good shell which works on Windows - I tried cygwin and lot of others, but I don't want UNIX emulation (and their path emulations, gimme C:\_ dammit ;)) -- I just want workable bash-like shell, rest of toolkit is already provided with GNUWin32...

You cannot define a correlation name ‘foo’ more than once

This error haunted me last few days ... nothing on net which can indicate source of error, only one supposed solution was commenting out one line somewhere in core files = big no go for me.
After poking around and comparing why default themes work and mine don't even they functionally are the same I finally stumbled into real culprit
<action method="unsetChild">
As this is used to remove block "content" so one can add another in his place (as opposite to <remove name="foo"> which removes block entirely from XML) I used it to remove and re-create layered navigation so I can change order of blocks but...
Surely unsetChild will remove it but as far I can see original block will be still executed (I should known better fighting with other "logical" and "user configurable" decisions in magento before) - so with my code
<action method="unsetChild"><name>foo</name></action>
<block name="foo" ... />
I managed to call filtering function more than once which in turn produced error from title.
where I left my "bang head here" sticker...

P.S. granted I'm very new to magento so I maybe just made just plain ol' PEBKAC (or better yet ID10T error :P) who knows ...

P.P.S to paraphrase Jamie Zawinski:
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
on this case
Some people, when confronted with a problem, think "I know, I'll use XML." Now they have a LOT of trouble.

Tuesday, April 6, 2010

How to Change the Width of Window Border on Vista or Windows 7

Finally, after I gave up all hop that I'll manage to change that monstrous borders/title bars to something more usable I stumbled on this

How to Change the Width of Window Borders

Saturday, April 3, 2010

PSPad

In my never ending hunt for good windows programmer's editor I stumbled on this nice one.

PSPad for now (finally) looks as something that I can use for may day-to-day programing.

I specially like concept of virtual folders so I can pull out and organize files independent of real location on file system (really useful when working on magento theming as needed files are all over the place).

Monday, March 8, 2010

VirtualBox

Put sticker *bang head here* ... use it ... rinse and repeat ....

After managing to install 3 OSes on same machine (should I count macbook's OSX as 4th, hmmm) and juggling some time between them I (finally) remembered that I can simply virtualize ... *more banging*

Now, while my Ubuntu 8.04 LTS server happily ticking in a background VirtualBox (yes, old one but it's (more or less) exact clone of my deployment VPS server) - I got perfect testing grounds for sites before making changes on live server (as soon I finish next, I'll post my adventures with git/virtualenv/fabric/django deployment cycle).

Not to mention that snapshots are great tool to try things and recover after hosing box with some ludicrous setting (etckeeper can save you sometimes but not always).

And finally got a chance to test OpenSolaris without need to add (yet another) HDD in my poor PC :)

Wednesday, February 3, 2010

DISQUS

Just to mention this great tool for adding comments on sites ... totally external and working great

Sunday, February 22, 2009

Embeddable pastebin

While reading this post in comments I stumbled to great embeddable pastebin resource.

I'm using the GitHub for a while now but I newer noticed that I can use as a pastebin and even better as a embeddable code highlighter.

Thursday, February 12, 2009

CouchDB install on Mac OSX -- the Fink way

On CouchDB wiki there are instructions how to install it from source but with MacPorts which I don't use. So I ventured to install it using Fink.

1. Install required fink packages

2. Apple ICU implementation is not complete so we will build own (this applies to ICU 4.0.1, check paths on the ICU site).

3. Compile CouchDB from repository

4. Check /usr/local/etc/couchdb/local.ini

(see /usr/local/etc/couchdb/default.ini for available parameters)

(optional) If you want to autostart CouchDB check /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist and make required changes -- notably UserName and DYLD_LIBRARY_PATH keys. Make sure that user defined here have write privileges in dirs defined in default.ini or local.ini:

And add this to launchd:

5. Start CouchDB

Now you can use Futon to browse database and also you can verify your instalation by running test suite.