Example #1
0
 protected function _getLinkAttr($linkType, $linkAttr = null, $param = null)
 {
     if (!is_null($linkType)) {
         $linkTypeId = is_numeric($linkType) ? $linkType : $this->_getLinkTypeId($linkType);
     }
     if (empty($this->_linkAttrs)) {
         $attrs = $this->_read->fetchAll("select * from {$this->_t("catalog/product_link_attribute")}");
         foreach ($attrs as $a) {
             $this->_linkAttrs[$a['link_type_id']][$a['product_link_attribute_code']] = array("id" => $a['product_link_attribute_id'], "code" => $a['product_link_attribute_code'], "data_type" => $a['data_type']);
             $this->_linkAttrIds[$a['product_link_attribute_id']] = $a['product_link_attribute_code'];
         }
     }
     if (is_null($linkType)) {
         return $this->_linkAttrs;
     }
     if (empty($this->_linkAttrs[$linkTypeId])) {
         Mage::throwexception($this->__("Invalid product link type (%s)", $linkType));
     }
     if (is_null($linkAttr)) {
         return $this->_linkAttrs[$linkTypeId];
     }
     if (is_numeric($linkAttr) && !empty($this->_linkAttrIds[$linkAttr])) {
         $linkAttr = $this->_linkAttrIds[$linkAttr];
     }
     if (empty($this->_linkAttrs[$linkTypeId][$linkAttr])) {
         Mage::throwexception($this->__("Invalid product link attribute (%s, %s)", $linkType, $linkAttr));
     }
     $attr = $this->_linkAttrs[$linkTypeId][$linkAttr];
     return is_null($param) ? $attr : $attr[$param];
 }
Example #2
0
 protected function _getAttributeSetFields($attrSet)
 {
     if ($attrSet && !is_numeric($attrSet)) {
         $attrSet = $this->_attr("product.attribute_set", "options_bytext", strtolower($attrSet));
     }
     if (!$attrSet) {
         Mage::throwexception($this->__("Invalid attribute set"));
     }
     if (empty($this->_attributeSetFields[$attrSet])) {
         $this->_attributeSetFields[$attrSet] = $this->_write->fetchPairs("select a.attribute_code, a.attribute_id from {$this->_t("eav/entity_attribute")} ea inner join {$this->_t("eav/attribute")} a on a.attribute_id=ea.attribute_id where attribute_set_id={$attrSet}");
     }
     return $this->_attributeSetFields[$attrSet];
 }
Example #3
0
 protected function _deleteRowEAOL($row)
 {
     if (sizeof($row) < 4) {
         Mage::throwexception($this->__("Invalid row format"));
     }
     $aTable = $this->_t("eav/attribute");
     $oTable = $this->_t("eav/attribute_option");
     $olTable = $this->_t("eav/attribute_option_value");
     $label = $this->_convertEncoding($row[2]);
     $etId = $this->_getEntityType(!empty($row[4]) ? $row[4] : "catalog_product", "entity_type_id");
     if (!$etId) {
         $this->_profile->getLogger()->setColumn(5);
         Mage::throwexception($this->__("Invalid entity type"));
     }
     $sId = $this->_getStoreId($row[3]);
     if ($this->_skipStore($sId, 4)) {
         return self::IMPORT_ROW_RESULT_NOCHANGE;
     }
     $existsId = $this->_write->fetchOne("select ol.value_id from {$oTable} o\n            inner join {$aTable} a on a.attribute_id=o.attribute_id\n            inner join {$olTable} od on od.option_id=o.option_id and od.store_id=0\n            inner join {$olTable} ol on ol.option_id=o.option_id and ol.store_id={$sId}\n            where a.entity_type_id={$etId} and a.attribute_code={$this->_write->quote($row[1])} and od.value={$this->_write->quote($label)}");
     if ($existsId) {
         $this->_write->delete($olTable, "value_id={$existsId}");
         return self::IMPORT_ROW_RESULT_SUCCESS;
     }
     return self::IMPORT_ROW_RESULT_NOCHANGE;
 }