~openlabs/magentoerpconnect/magento-module

« back to all changes in this revision

Viewing changes to code/community/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php

  • Committer: Sharoon Thomas
  • Date: 2009-08-27 14:31:03 UTC
  • Revision ID: sharoonthomas@teagarden.in-20090827143103-5sab07jh6n41mwkf
[UPD]Working category image api

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * @copyright 2009
8
8
 */
9
9
 
10
 
class Openlabs_OpenERPConnector_Model_Olcatalog_Categories extends Mage_Catalog_Model_Api_Resource {
 
10
class Openlabs_OpenERPConnector_Model_Olcatalog_Categories extends Mage_Catalog_Model_Api_Resource 
 
11
{
11
12
        public function items($filters = null) {
12
13
                try {
13
14
                        $collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image');
53
54
                                                                $img_data = base64_encode($imagebin);
54
55
                                                                fclose($fp);
55
56
                                                        } catch (Exception $e) {
56
 
                                                                return "exc proc";
 
57
                                                                $this->_fault('not_media');
57
58
                                                        }
58
59
                                                }
59
60
                                                $result[] = array (
74
75
 
75
76
        }
76
77
 
77
 
        public function create($filename, $imagedata) {
78
 
                if ($filename and $imagedata) {
79
 
                        try {
80
 
                                if ($filename) {
81
 
                                        $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
82
 
                                        $fullpath = $path . $filename;
83
 
                                        try {
84
 
                                                $fp = fopen($fullpath, "wb");
85
 
                                                $image = fwrite($fp, base64_decode($imagedata));
86
 
                                                fclose($fp);
87
 
                                        } catch (Exception $e) {
88
 
                                                return "exc proc";
89
 
                                        }
90
 
                                }
91
 
                                return true;
92
 
                        }
93
 
                }
 
78
public function create($filename,$imgdata) {
 
79
        if ($filename)
 
80
        {
 
81
                $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
 
82
                $fullpath = $path . $filename;
 
83
                try
 
84
                {
 
85
                        $fp = fopen($fullpath, "wb");
 
86
                        $img_data = base64_decode($imgdata);
 
87
                        //return $img_data;
 
88
                        $imagebin = fwrite($fp,$img_data);
 
89
                        fclose($fp);
 
90
                }
 
91
                catch (Exception $e) 
 
92
                {
 
93
                        $this->_fault('not_created');
 
94
                }
 
95
                return true;
94
96
        }
95
97
}
 
98
}
96
99
?>