Example #1
0
 public function render(Varien_Object $row)
 {
     $result = '';
     if ($row['type_id'] == 'bundle' || $row['type_id'] == 'configurable' || $row['type_id'] == 'grouped') {
         $result = '<a href="javascript:;" data-product-id="' . $row['entity_id'] . '" data-type-id="' . $row['type_id'] . '" class="a-expan-child">Expand Child</a>';
     } else {
         if (isset($row['custom_option']) && $row['custom_option']) {
             $id = $row['entity_id'] . "_" . $row['option_id'] . "_" . $row->getEntityTypeId();
         } elseif (isset($row['super_attribute']) && $row['super_attribute']) {
             $id = $row['option_id'] . "_" . $row['entity_id'] . "_" . $row['custom_attribute_id'];
         } else {
             $id = $row['entity_id'];
         }
         //$class = "input-text validate-number validate-digits";
         if (isset($row['super_attribute']) && $row['super_attribute']) {
             $name = 'mw_reward_point_sell_product[super_attribute_' . $id . ']';
         } else {
             $name = 'mw_reward_point_sell_product[mw_' . $id . ']';
         }
         if (isset($row['custom_option']) || isset($row['super_attribute'])) {
             $model = Mage::getModel('rewardpoints/productsellpoint');
             if (isset($row['custom_option']) && $row['custom_option']) {
                 $collection = $model->getCollection()->addFieldToFilter('product_id', $row['entity_id'])->addFieldToFilter('option_id', $row['option_id'])->addFieldToFilter('option_type_id', $row['entity_type_id'])->addFieldToFilter('type_id', 'custom_option')->getFirstItem();
             } else {
                 $collection = $model->getCollection()->addFieldToFilter('product_id', $row['option_id'])->addFieldToFilter('option_id', $row['entity_id'])->addFieldToFilter('option_type_id', $row['custom_attribute_id'])->addFieldToFilter('type_id', 'super_attribute')->getFirstItem();
             }
             $value = $collection->getSellPoint();
         } else {
             $value = $row['mw_reward_point_sell_product'];
         }
         //$result = "<span style='display: block; margin: 0px 0px 0px 8px;'>".$value."</span><input type=".$type." class=".$class." name=".$name." value=".$value."></input>";
         $result = "  <input type='text' class='input-text validate-number' style='width: 80px !important' name=" . $name . " value=" . $value . "></input>";
     }
     return $result;
 }
Example #2
0
 public function render(Varien_Object $row)
 {
     $result = '';
     if (isset($row['custom_option']) && $row['custom_option']) {
         $id = $row['entity_id'] . "_" . $row['option_id'] . "_" . $row->getEntityTypeId();
     } elseif (isset($row['super_attribute']) && $row['super_attribute']) {
         $id = $row['option_id'] . "_" . $row['entity_id'] . "_" . $row['custom_attribute_id'];
     } else {
         $id = $row['entity_id'];
     }
     //$class = "input-text validate-number validate-digits";
     if (isset($row['super_attribute']) && $row['super_attribute']) {
         $name = 'reward_point_product[super_attribute_' . $id . ']';
     } else {
         $name = 'reward_point_product[mw_' . $id . ']';
     }
     if (isset($row['custom_option']) || isset($row['super_attribute'])) {
         $model = Mage::getModel('rewardpoints/productsellpoint');
         if (isset($row['custom_option']) && $row['custom_option']) {
             $collection = $model->getCollection()->addFieldToFilter('product_id', $row['entity_id'])->addFieldToFilter('option_id', $row['option_id'])->addFieldToFilter('option_type_id', $row['entity_type_id'])->addFieldToFilter('type_id', 'custom_option')->getFirstItem();
         } else {
             $collection = $model->getCollection()->addFieldToFilter('product_id', $row['option_id'])->addFieldToFilter('option_id', $row['entity_id'])->addFieldToFilter('option_type_id', $row['custom_attribute_id'])->addFieldToFilter('type_id', 'super_attribute')->getFirstItem();
         }
         $value = $collection->getEarnPoint();
     } else {
         $value = $row['reward_point_product'];
     }
     //$result = "<span style='display: block; margin: 0px 0px 0px 8px;'>".$value."</span><input type=".$type." class=".$class." name=".$name." value=".$value."></input>";
     $result = "  <input type='text' class='input-text validate-number' style='width: 80px !important' name=" . $name . " value=" . $value . "></input>";
     return $result;
 }
 /**
  * Delete entity attribute values
  *
  * @param Varien_Object $object
  * @param string $table
  * @param array $info
  * @return Mage_Catalog_Model_Resource_Abstract
  */
 protected function _deleteAttributes($object, $table, $info)
 {
     $adapter = $this->_getWriteAdapter();
     $entityIdField = $this->getEntityIdField();
     $globalValues = array();
     $websiteAttributes = array();
     $storeAttributes = array();
     /**
      * Separate attributes by scope
      */
     foreach ($info as $itemData) {
         $attribute = $this->getAttribute($itemData['attribute_id']);
         if ($attribute->isScopeStore()) {
             $storeAttributes[] = (int) $itemData['attribute_id'];
         } elseif ($attribute->isScopeWebsite()) {
             $websiteAttributes[] = (int) $itemData['attribute_id'];
         } else {
             $globalValues[] = (int) $itemData['value_id'];
         }
     }
     /**
      * Delete global scope attributes
      */
     if (!empty($globalValues)) {
         $adapter->delete($table, array('value_id IN (?)' => $globalValues));
     }
     $condition = array($entityIdField . ' = ?' => $object->getId(), 'entity_type_id = ?' => $object->getEntityTypeId());
     /**
      * Delete website scope attributes
      */
     if (!empty($websiteAttributes)) {
         $storeIds = $object->getWebsiteStoreIds();
         if (!empty($storeIds)) {
             $delCondition = $condition;
             $delCondition['attribute_id IN(?)'] = $websiteAttributes;
             $delCondition['store_id IN(?)'] = $storeIds;
             $adapter->delete($table, $delCondition);
         }
     }
     /**
      * Delete store scope attributes
      */
     if (!empty($storeAttributes)) {
         $delCondition = $condition;
         $delCondition['attribute_id IN(?)'] = $storeAttributes;
         $delCondition['store_id = ?'] = (int) $object->getStoreId();
         $adapter->delete($table, $delCondition);
     }
     return $this;
 }
Example #4
0
 /**
  * Delete entity attribute values
  *
  * @param   Varien_Object $object
  * @param   string $table
  * @param   array $info
  * @return  Varien_Object
  */
 protected function _deleteAttributes($object, $table, $info)
 {
     $entityIdField = $this->getEntityIdField();
     $globalValues = array();
     $websiteAttributes = array();
     $storeAttributes = array();
     /**
      * Separate attributes by scope
      */
     foreach ($info as $itemData) {
         $attribute = $this->getAttribute($itemData['attribute_id']);
         if ($attribute->isScopeStore()) {
             $storeAttributes[] = $itemData['attribute_id'];
         } elseif ($attribute->isScopeWebsite()) {
             $websiteAttributes[] = $itemData['attribute_id'];
         } else {
             $globalValues[] = $itemData['value_id'];
         }
     }
     /**
      * Delete global scope attributes
      */
     if (!empty($globalValues)) {
         $condition = $this->_getWriteAdapter()->quoteInto('value_id IN (?)', $globalValues);
         $this->_getWriteAdapter()->delete($table, $condition);
     }
     $condition = $this->_getWriteAdapter()->quoteInto("{$entityIdField}=?", $object->getId()) . $this->_getWriteAdapter()->quoteInto(' AND entity_type_id=?', $object->getEntityTypeId());
     /**
      * Delete website scope attributes
      */
     if (!empty($websiteAttributes)) {
         $storeIds = $object->getWebsiteStoreIds();
         if (!empty($storeIds)) {
             $delCondition = $condition . $this->_getWriteAdapter()->quoteInto(' AND attribute_id IN(?)', $websiteAttributes) . $this->_getWriteAdapter()->quoteInto(' AND store_id IN(?)', $storeIds);
             $this->_getWriteAdapter()->delete($table, $delCondition);
         }
     }
     /**
      * Delete store scope attributes
      */
     if (!empty($storeAttributes)) {
         $delCondition = $condition . $this->_getWriteAdapter()->quoteInto(' AND attribute_id IN(?)', $storeAttributes) . $this->_getWriteAdapter()->quoteInto(' AND store_id =?', $object->getStoreId());
         $this->_getWriteAdapter()->delete($table, $delCondition);
     }
     return $this;
 }
Example #5
0
 /**
  * Insert entity attribute value
  *
  * @param   Varien_Object $object
  * @param   Mage_Eav_Model_Entity_Attribute_Abstract $attribute
  * @param   mixed $value
  * @return  Mage_Eav_Model_Entity_Abstract
  */
 protected function _insertAttribute($object, $attribute, $value)
 {
     $entityIdField = $attribute->getBackend()->getEntityIdField();
     $row = array($entityIdField => $object->getId(), 'entity_type_id' => $object->getEntityTypeId(), 'attribute_id' => $attribute->getId(), 'value' => $this->_prepareValueForSave($value, $attribute));
     $this->_getWriteAdapter()->insert($attribute->getBackend()->getTable(), $row);
     return $this;
 }