栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何仅使用mysql在magento中提取所有产品ID,Skus,产品名称,说明?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何仅使用mysql在magento中提取所有产品ID,Skus,产品名称,说明?

一个商店视图的标题可能与另一个商店视图的标题不同。相同的描述。另外,某些商店视图可以使用后端中设置的默认值。

这是有关如何获取特定商店视图(标识1)的所有产品所需的数据(SKU,名称,说明)的完整查询。

SELECt     `e`.`sku`,     IF(at_name.value_id > 0, at_name.value, at_name_default.value) AS `name`,    IF(at_description.value_id > 0, at_description.value, at_description_default.value) AS `description`FROM    `catalog_product_entity` AS `e`     INNER JOIN          `catalog_product_entity_varchar` AS `at_name_default`     ON (`at_name_default`.`entity_id` = `e`.`entity_id`) AND        (`at_name_default`.`attribute_id` = (SELECt attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERe `ea`.`attribute_pre` = 'name' AND et.entity_type_pre = 'catalog_product')) AND        `at_name_default`.`store_id` = 0     LEFT JOIN`catalog_product_entity_varchar` AS `at_name`     ON (`at_name`.`entity_id` = `e`.`entity_id`) AND        (`at_name`.`attribute_id` = (SELECt attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERe `ea`.`attribute_pre` = 'name' AND et.entity_type_pre = 'catalog_product')) AND        (`at_name`.`store_id` = 1)     INNER JOIN          `catalog_product_entity_text` AS `at_description_default`     ON (`at_description_default`.`entity_id` = `e`.`entity_id`) AND        (`at_description_default`.`attribute_id` = (SELECt attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERe `ea`.`attribute_pre` = 'description' AND et.entity_type_pre = 'catalog_product')) AND        `at_description_default`.`store_id` = 0     LEFT JOIN`catalog_product_entity_text` AS `at_description`     ON (`at_description`.`entity_id` = `e`.`entity_id`) AND        (`at_description`.`attribute_id` = (SELECt attribute_id FROM `eav_attribute` ea LEFT JOIN `eav_entity_type` et ON ea.entity_type_id = et.entity_type_id  WHERe `ea`.`attribute_pre` = 'description' AND et.entity_type_pre = 'catalog_product')) AND        (`at_description`.`store_id` = 1)

如果您希望将其用于其他商店视图,只需

1
在以下几行中将值替换为所需的ID

(`at_name`.`store_id` = 1)

(`at_description`.`store_id` = 1)

我不知道为什么您需要sql格式的文件。这是一个奇怪且大的错误源。您可以通过代码轻松获得它:

$collection = Mage::getResourceModel('catalog/product_collection')        ->addAttributeToSelect(array('sku', 'name', 'description'));foreach ($collection as $item) {    $sku = $item->getSku();    $name = $item->getName();    $description = $item->getDescription();     //do something with $sku, $name & $description}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/400711.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号