try catch mistakes

To cope with errors in code we can do many thing, among many approaches the most powerful is to use “try catch finally” block around the code that might cause trouble (one we know that it throws Errors) but what I have noticed working with different programmers common mistake is to use “try catch” block as a filter of errors.
Continue reading

Posted in actionscript, flash | Tagged , , | Comments Off on try catch mistakes

URLLoader and Loader classes

Have you ever had mystery errors that your content stopped working without a reason? Possibly you haven’t registered all important listeners, most examples are simplified, i.e.

var image:Loader = new Loader();
image.addeventListener(Event.COMPLETE, onImageLoaded);
image.load(new URLRequest("myImage.jpg"));

Continue reading

Posted in actionscript, flash | Tagged , , | Comments Off on URLLoader and Loader classes

Magento API bug in catalog_category.level

More frustration every day:( I hoped to breeze through basic and core API but so far there are just issues, I have tried to use level method to pull single levels of category tree instead of receiving gigantic structure using tree method, but it was just beyond me. The level method when called without arguments should return top level category – works, then it accepts 3 arguments more to filter out the results, the website code, the store view code and parent category id, all according to documentation optional. But the method body…

    /**
     * Retrive level of categories for category/store view/website
     *
     * @param string|int $website
     * @param string|int $store
     * @return array
     */
    public function level($website = null, $store = null, $categoryId = null)
    {
        $ids = array();
        $storeId = Mage_Catalog_Model_Category::DEFAULT_STORE_ID;
		$this->_fault('website_not_exists',  var_dump($website));
        // load root categories of website
        if (null !== $website) {
            try {
                $website = Mage::app()->getWebsite($website);
                foreach ($website->getStores() as $store) {
                    /* @var $store Mage_Core_Model_Store */
                    $ids[] = $store->getRootCategoryId();
                }
            } catch (Mage_Core_Exception $e) {
                $this->_fault('website_not_exists', $e->getMessage());
            }
        }
        elseif (null !== $store) {
            // load children of root category of store
            if (null === $categoryId) {
                try {
                    $store = Mage::app()->getStore($store);
                    $storeId = $store->getId();
                    $ids = $store->getRootCategoryId();
                } catch (Mage_Core_Model_Store_Exception $e) {
                    $this->_fault('store_not_exists');
                }
            }
            // load children of specified category id
            else {
                $storeId = $this->_getStoreId($store);
                $ids = (int)$categoryId;
            }
        }
//[...]
    }

Continue reading

Posted in magento | Tagged , , | Comments Off on Magento API bug in catalog_category.level

Things to remember when calling API methods

It’s been frustrating hour, I’ve been sitting and trying to figure it out why my call to sales_order.list doesn’t work, I thought “it can’t be” everything is fine (looks like) but it returns

faultCode=620 faultMessage=”Method “sales_order.list” does not exist”

Continue reading

Posted in magento, xml-rpc | Tagged , | Comments Off on Things to remember when calling API methods

Magento API – resources method

Still didn’t gave up on this, following is the update on my progress. I have created in magento 3 types of roles, admin, read only and customer. I wanted to check what is the difference from the API point of view. I have browsed the documentation (rather a brief list then documentation) and have found in Magento Core API the “resources” method.
Continue reading

Posted in magento, xml-rpc | Tagged , , | Comments Off on Magento API – resources method