/** * Return relation info about used products * * @return Varien_Object Object with information data */ public function getRelationInfo() { $info = new Varien_Object(); $info->setTable('catalog/product_link')->setParentFieldName('product_id')->setChildFieldName('linked_product_id')->setWhere('link_type_id=' . Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED); return $info; }
/** * Return relation info about used products * * @return Varien_Object Object with information data */ public function getRelationInfo() { $info = new Varien_Object(); $info->setTable('bundle/selection')->setParentFieldName('parent_product_id')->setChildFieldName('product_id'); return $info; }
/** * Return relation info about used products * * @return Varien_Object Object with information data */ public function getRelationInfo() { $info = new Varien_Object(); $info->setTable('catalog/product_super_link')->setParentFieldName('parent_id')->setChildFieldName('product_id'); return $info; }
/** * @param Varien_Object $context * @param Varien_Simplexml_Element $module * @param Varien_Simplexml_Element $entity * @param Varien_Simplexml_Element $scope */ public function _endTableScript($context, $module, $entity, $scope) { $scope = $scope; if (!empty($scope->unique)) { /* @var $resource Mage_Core_Model_Mysql4_Resource */ $resource = Mage::getResourceSingleton('core/resource'); $indexes = $context->getIndexes(); foreach ($scope->unique->children() as $unique) { $index = (object) array('unique' => 1, 'name' => 'unique_' . $unique->getName(), 'indexed_fields' => array()); $includeUniqueIndex = false; foreach ($unique->children() as $field => $def) { if ((string) $def['module'] == $this->getModuleName() && (string) $def['version'] == $this->getVersion()) { $includeUniqueIndex = true; $index->indexed_fields[] = $field; } else { $installedVersion = $resource->getDbVersion((string) $def['module'] . '_setup'); if ($installedVersion && version_compare($installedVersion, (string) $def['version']) >= 0) { $index->indexed_fields[] = $field; } } } if ($includeUniqueIndex) { if (!((string) $scope->unique['module'] == $this->getModuleName() && (string) $scope->unique['version'] == $this->getVersion())) { $index->rebuild = true; } $indexes[] = $index; } } $context->setIndexes($indexes); } $sql = $context->getSql(); $context->setTable($this->getTable((string) $module->name . '/' . (string) $entity->name . '/' . (string) $scope->name)); if ((string) $scope['module'] != $this->getModuleName() || (string) $scope['version'] != $this->getVersion()) { foreach ($context->getFields() as $field) { $sql .= "ALTER TABLE `{$context->getTable()}` ADD COLUMN ( "; $sql .= $this->_renderField($field); $sql .= ");\n"; } foreach ($context->getIndexes() as $index) { if (!empty($index->rebuild)) { $sql .= "ALTER TABLE `{$context->getTable()}` DROP KEY `" . (string) $index->name . "`"; $sql .= ";\n"; } $sql .= "ALTER TABLE `{$context->getTable()}` ADD "; $sql .= $this->_renderIndex($index); $sql .= ";\n"; } } else { if (count($context->getFields()) || count($context->getIndexes())) { $sql .= "DROP TABLE IF EXISTS `{$context->getTable()}`;\n"; $sql .= "CREATE TABLE `{$context->getTable()}` ( \n"; $sep = false; foreach ($context->getFields() as $field) { if ($sep) { $sql .= ", \n"; } else { $sep = true; } $sql .= " " . $this->_renderField($field); } foreach ($context->getIndexes() as $index) { if ($sep) { $sql .= ", \n"; } else { $sep = true; } $sql .= " " . $this->_renderIndex($index); } $sql .= "\n"; $sql .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='';\n"; } } foreach ($context->getConstraints() as $constraint) { $sql .= "ALTER TABLE `{$context->getTable()}` ADD CONSTRAINT "; $sql .= $this->_renderConstraint($context, $constraint); $sql .= ";\n"; } $context->setSql($sql); }