Esempio n. 1
0
 /**
  * Retrive Vendor attribute collection
  *
  * @return Mage_Eav_Model_Resource_Entity_Collection
  */
 public function getCollection()
 {
     $collection = parent::getCollection();
     $typeId = Mage::getModel('csmarketplace/vendor')->getEntityTypeId();
     $collection = $collection->addFieldToFilter('entity_type_id', array('eq' => $typeId));
     $labelTableName = Mage::getSingleton('core/resource')->getTableName('eav/attribute_label');
     $tableName = Mage::getSingleton('core/resource')->getTableName('csmarketplace/vendor_form');
     if ($this->getStoreId()) {
         $availableStoreWiseIds = $this->getStoreWiseIds($this->getStoreId());
         $collection->getSelect()->join(array('vform' => $tableName), 'main_table.attribute_id=vform.attribute_id', array('is_visible' => 'vform.is_visible', 'sort_order' => 'vform.sort_order', 'store_id' => 'vform.store_id', 'use_in_registration' => 'vform.use_in_registration', 'use_in_left_profile' => 'vform.use_in_left_profile', 'position_in_registration' => 'vform.position_in_registration', 'position_in_left_profile' => 'vform.position_in_left_profile', 'fontawesome_class_for_left_profile' => 'vform.fontawesome_class_for_left_profile'));
         $collection->getSelect()->where('(vform.attribute_id IN ("' . $availableStoreWiseIds . '") AND vform.store_id=' . $this->getStoreId() . ') OR (vform.attribute_id NOT IN ("' . $availableStoreWiseIds . '") AND vform.store_id=0)');
         $collection->getSelect()->group('vform.attribute_id');
         $collection->getSelect()->joinLeft(array('vlabel' => $labelTableName), 'main_table.attribute_id=vlabel.attribute_id && vlabel.store_id=' . $this->getStoreId(), array('store_label' => 'vlabel.value'));
     } else {
         $collection->getSelect()->join(array('vform' => $tableName), 'main_table.attribute_id=vform.attribute_id && vform.store_id=0', array('is_visible' => 'vform.is_visible', 'sort_order' => 'vform.sort_order', 'store_id' => 'vform.store_id', 'use_in_registration' => 'vform.use_in_registration', 'use_in_left_profile' => 'vform.use_in_left_profile', 'position_in_registration' => 'vform.position_in_registration', 'position_in_left_profile' => 'vform.position_in_left_profile', 'fontawesome_class_for_left_profile' => 'vform.fontawesome_class_for_left_profile'));
         $collection->getSelect()->joinLeft(array('vlabel' => $labelTableName), 'main_table.attribute_id=vlabel.attribute_id && vlabel.store_id=0', array('store_label' => 'vlabel.value'));
     }
     /* $collection->addExpressionFieldToSelect("is_visible","(CASE WHEN `"."vform"."`.`is_visible` IS NULL THEN (SELECT `".$tableName."`.`is_visible` from `".$tableName."` WHERE `".$tableName."`.`store_id`=0 AND `".$tableName."`.`attribute_id`=`vform`.`attribute_id`) ELSE `"."vform"."`.`is_visible` END)", "");
     		echo $collection->getSelect();die; */
     return $collection;
 }