Example #1
0
 /**
  * Join a meta field to the query
  *
  * @param string $field
  * @return $this
  */
 protected function _joinMetaField($field)
 {
     $model = $this->getNewEmptyItem();
     if ($model->hasMeta()) {
         if (!isset($this->_metaFieldsJoined[$field])) {
             $alias = $this->_getMetaFieldAlias($field);
             $meta = new Varien_Object(array('key' => $field, 'alias' => $alias));
             Mage::dispatchEvent($model->getEventPrefix() . '_join_meta_field', array('collection' => $this, 'meta' => $meta));
             if ($meta->getCanSkipJoin()) {
                 $this->_metaFieldsJoined[$field] = $meta->getAlias();
             } else {
                 $condition = "`{$alias}`.`{$model->getMetaObjectField()}`=`main_table`.`{$model->getResource()->getIdFieldName()}` AND " . $this->getConnection()->quoteInto("`{$alias}`.`meta_key`=?", $field);
                 $this->getSelect()->joinLeft(array($alias => $model->getMetaTable()), $condition, '');
                 $this->_metaFieldsJoined[$field] = $alias . '.meta_value';
             }
         }
         return $this->_metaFieldsJoined[$field];
     }
     return false;
 }
Example #2
0
 public function render(Varien_Object $row)
 {
     $urlModel = Mage::getModel('core/url')->setStore($row->getData('_first_store_id'));
     $href = $urlModel->getUrl($row->getAlias(), array('_current' => false, '_query' => '___store=' . $row->getStoreCode()));
     return '<a href="' . $href . '" target="_blank">' . $this->__('Preview') . '</a>';
 }