Ejemplo n.º 1
0
 /**
  * Enter description here ...
  * @param Morphes_Db_Model_Replication_Target $target
  */
 protected function _prepareReplicationInsertSelects($target, $options)
 {
     /* @var $select Varien_Db_Select */
     $select = $options['db']->select();
     $select->from(array('eav_attribute' => Mage::getSingleton('core/resource')->getTableName('eav/attribute')), null)->joinInner(array('eav_attribute_option' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option')), 'eav_attribute.attribute_id = eav_attribute_option.attribute_id', 'eav_attribute_option.option_id AS option_id')->joinInner(array('parent' => Mage::getSingleton('core/resource')->getTableName('morphes_filters/filter2')), 'eav_attribute.attribute_code = parent.code', 'parent.id AS filter_id')->joinLeft(array('global_option_value' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value')), 'global_option_value.option_id = eav_attribute_option.option_id AND global_option_value.store_id = 0', null)->joinLeft(array('target' => Mage::getSingleton('core/resource')->getTableName($this->getEntityName())), 'target.option_id = eav_attribute_option.option_id', null)->distinct()->where('target.id IS NULL')->columns(array('global_option_value.value_id AS value_id', 'global_option_value.value AS name', 'eav_attribute_option.sort_order AS position'));
     if ($options['trackKeys']) {
         if (($keys = $options['targets']['eav/attribute']->getSavedKeys()) && count($keys)) {
             $select->where('eav_attribute.attribute_id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
         if (($keys = $options['targets']['morphes_filters/filter2']->getSavedKeys()) && count($keys)) {
             $select->where('parent.id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
     }
     $target->setSelect('main', $select);
 }
Ejemplo n.º 2
0
 /**
  * Enter description here ...
  * @param Morphes_Db_Model_Replication_Target $target
  */
 protected function _prepareReplicationInsertSelects($target, $options)
 {
     $globalEntityName = Mage::helper('morphes_db')->getGlobalEntityName($this->getEntityName());
     /* @var $select Varien_Db_Select */
     $select = $options['db']->select();
     $select->from(array('global' => Mage::getSingleton('core/resource')->getTableName($globalEntityName)), 'global.id AS global_id')->from(array('core_store' => Mage::getSingleton('core/resource')->getTableName('core_store')), 'core_store.store_id AS store_id')->joinInner(array('eav_attribute_option' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option')), 'global.option_id = eav_attribute_option.option_id', null)->joinInner(array('eav_attribute' => Mage::getSingleton('core/resource')->getTableName('eav/attribute')), 'eav_attribute.attribute_id = eav_attribute_option.attribute_id', null)->joinInner(array('parent_global' => Mage::getSingleton('core/resource')->getTableName('morphes_filters/filter2')), 'eav_attribute.attribute_code = parent_global.code', null)->joinInner(array('parent' => Mage::getSingleton('core/resource')->getTableName('morphes_filters/filter2_store')), 'parent_global.id = parent.global_id AND core_store.store_id = parent.store_id', 'parent.id AS filter_id')->joinLeft(array('global_option_value' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value')), 'global_option_value.option_id = eav_attribute_option.option_id AND global_option_value.store_id = 0', null)->joinLeft(array('store_option_value' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value')), 'store_option_value.option_id = eav_attribute_option.option_id AND store_option_value.store_id = core_store.store_id', null)->joinLeft(array('target' => Mage::getSingleton('core/resource')->getTableName($this->getEntityName())), 'target.global_id = global.id AND target.store_id = core_store.store_id', null)->distinct()->where('core_store.store_id <> 0')->where('global.edit_status = 0')->where('target.id IS NULL')->columns(array('global.option_id AS option_id', 'COALESCE(store_option_value.value_id, global_option_value.value_id) AS value_id', "COALESCE(store_option_value.value, global_option_value.value, '') AS name", 'global.position AS position'));
     if ($options['trackKeys']) {
         if (($keys = $options['targets']['eav/attribute']->getSavedKeys()) && count($keys)) {
             $select->where('eav_attribute_option.attribute_id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
         if (($keys = $options['targets'][$globalEntityName]->getSavedKeys()) && count($keys)) {
             $select->where('global.id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
         if (($keys = $options['targets']['morphes_filters/filter2_store']->getSavedKeys()) && count($keys)) {
             $select->where('parent.id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
     }
     $target->setSelect('main', $select);
 }
Ejemplo n.º 3
0
 /**
  * Enter description here ...
  * @param Morphes_Db_Model_Replication_Target $target
  */
 protected function _prepareReplicationDeleteSelects($target, $options)
 {
     if ($options['trackKeys']) {
         if (($keys = $options['targets']['eav/attribute']->getDeletedKeys()) && count($keys)) {
             $attributeJoin = '';
             //$attributeJoin = ' AND '.$options['db']->quoteInto('eav_attribute.attribute_id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         } else {
             $attributeJoin = '';
         }
     } else {
         $attributeJoin = '';
     }
     /* @var $select Varien_Db_Select */
     $select = $options['db']->select();
     $select->from(array('target' => Mage::getSingleton('core/resource')->getTableName($this->getEntityName())), 'target.id AS id')->joinLeft(array('eav_attribute' => Mage::getSingleton('core/resource')->getTableName('eav/attribute')), 'target.code = eav_attribute.attribute_code' . $attributeJoin, null)->joinLeft(array('eav_attribute_additional' => Mage::getSingleton('core/resource')->getTableName('catalog/eav_attribute')), 'eav_attribute.attribute_id = eav_attribute_additional.attribute_id', null)->distinct()->where('(eav_attribute.attribute_id IS NULL) OR (eav_attribute_additional.is_filterable = 0)')->where("target.code <> 'category'");
     $target->setSelect('main', $select);
 }
Ejemplo n.º 4
0
 /**
  * Enter description here ...
  * @param Morphes_Db_Model_Replication_Target $target
  */
 protected function _prepareReplicationInsertSelects($target, $options)
 {
     $globalEntityName = Mage::helper('morphes_db')->getGlobalEntityName($this->getEntityName());
     /* @var $select Varien_Db_Select */
     $select = $options['db']->select();
     $select->from(array('global' => Mage::getSingleton('core/resource')->getTableName($globalEntityName)), 'global.id AS global_id')->from(array('core_store' => Mage::getSingleton('core/resource')->getTableName('core_store')), 'core_store.store_id AS store_id')->joinLeft(array('target' => Mage::getSingleton('core/resource')->getTableName($this->getEntityName())), 'target.global_id = global.id AND target.store_id = core_store.store_id', null)->joinLeft(array('eav_attribute' => Mage::getSingleton('core/resource')->getTableName('eav/attribute')), 'global.code = eav_attribute.attribute_code', null)->joinLeft(array('eav_attribute_label' => Mage::getSingleton('core/resource')->getTableName('eav/attribute_label')), 'eav_attribute.attribute_id = eav_attribute_label.attribute_id AND target.store_id = eav_attribute_label.store_id', null)->distinct()->where('core_store.store_id <> 0')->where('target.id IS NULL')->columns(array('global.is_enabled AS is_enabled', 'global.display AS display', 'COALESCE(eav_attribute_label.value, global.name) AS name', 'global.is_enabled_in_search AS is_enabled_in_search', 'global.position AS position', 'global.sort_method AS sort_method', 'global.operation AS operation', 'global.is_reverse AS is_reverse'));
     if ($options['trackKeys']) {
         if (($keys = $options['targets'][$globalEntityName]->getSavedKeys()) && count($keys)) {
             $select->where('global.id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
         if (($keys = $options['targets']['eav/attribute']->getSavedKeys()) && count($keys)) {
             $select->where('eav_attribute.attribute_id IN (?)', $keys);
             $target->setIsKeyFilterApplied(true);
         }
     }
     $target->setSelect('main', $select);
 }