Showing posts with label wtf??. Show all posts
Showing posts with label wtf??. 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!!!!

Wednesday, April 7, 2010

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.

Monday, March 8, 2010

DNSClient Windows problem (A.K.A nslookup radi sve ostalo ne)

Hehe, posle dužeg vremena naleteh na novi problem pod win kada sam pokušao da koristim DNS iz VM-a pod win.

OK, DNS se vidi, port 53 se javlja ... A/CNAME namešteni ... ubačen IP gde je DNS...

cmd.exe ....



!@#!@$!@$# ... google is your friend ... hmm

Izgleda da je krivac DNS Client servis:

The DNS Client service (dnscache) caches Domain Name System (DNS) names and registers the full computer name for this computer. If the service is stopped, DNS names will continue to be resolved. However, the results of DNS name queries will not be cached and the computer's name will not be registered. If the service is disabled, any services that explicitly depend on it will fail to start.


Čim je isključen svi DNS upiti su odlazili tamo gde treba, a pošto ionako bind 9 je definitivno bolji DNS keš nego on ... click ... disable ... sve je u redu :)

Monday, February 23, 2009

Besplatni internet -- jes of course ;)

OK, kasnim neki mesec ;)

Ali ovo je previše smešno da bi ga ignorisao -- besplatni wireless ("vajrles") internet 2 godine, wireless kamere ... enter the matrix Neo :D Jel' to idu neki izbori skoro pa nam opet mažu oči ... I još...
Telefoniranje preko interneta će građanima umanjiti račune za dva ili tri puta.
Baš će Telekom to da nam "pokloni", jedva se otkačismo (kao) monopola na telefoniju a da i ne pominjem njihov monopol na internet linkove...

Saturday, September 3, 2005

Netatalk

Another one bites the dust :)))


Ni ne pokušavajte da koristite netatalk koji dolazi uz ubuntu 5.04, naročito ako koristite OSX. Meni je posle (!?) upgrade-a sa warty-a na hoary prestalo da radi ripovanje sa afp diskova!


Takođe, iz neznanih razloga, na mojoj mašini je sve radilo ok kada priđem preko NFS-a (NFS i OSX, eee to će biti kada se naspavam, horor priče ostavljam za uveče) ili sambe (ne nisu prava pristupa). Ispade kao da sam namerno tako namestio. Moraću da nalovim krivca, Scitex^H^H^H^H^H^HCreo^H^H^H^HKodak nije kriv, nego neka glupost instalirana na druga dva mac-a, ma "iskopaće tebe Bili"™...


Naravno, ok, tu je i Netatalk - Networking Apple Macintosh through Open Source, ali onda genije dovuče CVS, ...., par sati kasnije (i posle gooomile apt-get-ova devel biblioteka), ..., tjmjkbžju, skinem arhivu i ... gle čuda radi ;D


Naravoučenije, nikada ne popravljaj server u petak popodne, naročito kada imaš posla u subotu.