Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_GoogleBase_Adminhtml_Googlebase_ItemsController
  • Mage_GoogleBase_Adminhtml_Googlebase_SelectionController
  • Mage_GoogleBase_Adminhtml_Googlebase_TypesController
  • Mage_GoogleBase_Block_Adminhtml_Captcha
  • Mage_GoogleBase_Block_Adminhtml_Items
  • Mage_GoogleBase_Block_Adminhtml_Items_Item
  • Mage_GoogleBase_Block_Adminhtml_Items_Product
  • Mage_GoogleBase_Block_Adminhtml_Store_Switcher
  • Mage_GoogleBase_Block_Adminhtml_Types
  • Mage_GoogleBase_Block_Adminhtml_Types_Edit
  • Mage_GoogleBase_Block_Adminhtml_Types_Edit_Attributes
  • Mage_GoogleBase_Block_Adminhtml_Types_Edit_Form
  • Mage_GoogleBase_Block_Adminhtml_Types_Grid
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_GoogleBase
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Products Grid to add to Google Base
 29:  *
 30:  * @category    Mage
 31:  * @package     Mage_GoogleBase
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_GoogleBase_Block_Adminhtml_Items_Product extends Mage_Adminhtml_Block_Widget_Grid
 35: {
 36: 
 37:     public function __construct()
 38:     {
 39:         parent::__construct();
 40:         $this->setId('googlebase_selection_search_grid');
 41:         $this->setDefaultSort('id');
 42:         $this->setUseAjax(true);
 43:     }
 44: 
 45:     protected function _beforeToHtml()
 46:     {
 47:         $this->setId($this->getId() . '_' . $this->getIndex());
 48:         $this->getChild('reset_filter_button')->setData('onclick', $this->getJsObjectName() . '.resetFilter()');
 49:         $this->getChild('search_button')->setData('onclick', $this->getJsObjectName() . '.doFilter()');
 50:         return parent::_beforeToHtml();
 51:     }
 52: 
 53:     protected function _prepareCollection()
 54:     {
 55:         $collection = Mage::getModel('catalog/product')->getCollection()
 56:             ->setStore($this->_getStore())
 57:             ->addAttributeToSelect('name')
 58:             ->addAttributeToSelect('sku')
 59:             ->addAttributeToSelect('price')
 60:             ->addAttributeToSelect('attribute_set_id');
 61: //            ->addFilterByRequiredOptions();
 62: 
 63:         $store = $this->_getStore();
 64:         if ($store->getId()) {
 65:             $collection->addStoreFilter($store);
 66:         }
 67: 
 68:         if ($excludeIds = $this->_getGoogleBaseProductIds()) {
 69:             $collection->addIdFilter($excludeIds, true);
 70:         }
 71: 
 72:         Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
 73: 
 74:         $this->setCollection($collection);
 75: 
 76:         return parent::_prepareCollection();
 77:     }
 78: 
 79:     protected function _prepareColumns()
 80:     {
 81:         $this->addColumn('id', array(
 82:             'header'    => Mage::helper('sales')->__('ID'),
 83:             'sortable'  => true,
 84:             'width'     => '60px',
 85:             'index'     => 'entity_id'
 86:         ));
 87:         $this->addColumn('name', array(
 88:             'header'    => Mage::helper('sales')->__('Product Name'),
 89:             'index'     => 'name',
 90:             'column_css_class'=> 'name'
 91:         ));
 92: 
 93:         $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
 94:             ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
 95:             ->load()
 96:             ->toOptionHash();
 97: 
 98:         $this->addColumn('type',
 99:             array(
100:                 'header'=> Mage::helper('catalog')->__('Type'),
101:                 'width' => '60px',
102:                 'index' => 'type_id',
103:                 'type'  => 'options',
104:                 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
105:         ));
106: 
107:         $this->addColumn('set_name',
108:             array(
109:                 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
110:                 'width' => '100px',
111:                 'index' => 'attribute_set_id',
112:                 'type'  => 'options',
113:                 'options' => $sets,
114:         ));
115: 
116:         $this->addColumn('sku', array(
117:             'header'    => Mage::helper('sales')->__('SKU'),
118:             'width'     => '80px',
119:             'index'     => 'sku',
120:             'column_css_class'=> 'sku'
121:         ));
122:         $this->addColumn('price', array(
123:             'header'    => Mage::helper('sales')->__('Price'),
124:             'align'     => 'center',
125:             'type'      => 'currency',
126:             'currency_code' => $this->_getStore()->getCurrentCurrencyCode(),
127:             'rate'      => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getCurrentCurrencyCode()),
128:             'index'     => 'price'
129:         ));
130: 
131:         return parent::_prepareColumns();
132:     }
133: 
134:     protected function _prepareMassaction()
135:     {
136:         $this->setMassactionIdField('product_id');
137:         $this->getMassactionBlock()->setFormFieldName('product');
138: 
139:         $this->getMassactionBlock()->addItem('add', array(
140:              'label'    => $this->__('Add to Google Base'),
141:              'url'      => $this->getUrl('*/*/massAdd', array('_current' => true)),
142:         ));
143:         return $this;
144:     }
145: 
146:     public function getGridUrl()
147:     {
148:         return $this->getUrl('*/googlebase_selection/grid', array('index' => $this->getIndex(), '_current' => true));
149:     }
150: 
151:     protected function _getGoogleBaseProductIds()
152:     {
153:         $collection = Mage::getResourceModel('googlebase/item_collection')
154:             ->addStoreFilterId($this->_getStore()->getId())
155:             ->load();
156:         $productIds = array();
157:         foreach ($collection as $item) {
158:             $productIds[] = $item->getProductId();
159:         }
160:         return $productIds;
161:     }
162: 
163:     protected function _getStore()
164:     {
165:         return Mage::app()->getStore($this->getRequest()->getParam('store'));
166:     }
167: }
168: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0