sql的方式修改产品属性 - 避免使用event (magento)
来源:互联网 发布:元数据定义都用大写吗 编辑:程序博客网 时间:2024/05/29 08:58
调用:
$this->updateAttribute($product_id,"1","is_edit","catalog_product_entity_text");
其中最后一个参数:catalog_product_entity_text,要注意,这个是这个属性的类型对应的表。
//保存产品的is_edit属性
private function updateAttribute($id,$values,$attribute,$tablename){ $connection = $this->getConnection('core_write'); $newvalues = $values; $productId = $id; $attributeId = $this->getAttributeId($attribute); if($this->checkIfIdExists($productId)){ $sql = "UPDATE " . $this->getTableName($tablename) . " cped SET cped.value = ? WHERE cped.attribute_id = ? AND cped.entity_id = ?"; $connection->query($sql, array($newvalues, $attributeId, $productId)); return 1; }else{ return 0; } } private function checkIfIdExists($id){ $connection = $this->getConnection('core_read'); $sql = "SELECT COUNT(*) AS count_no FROM " . $this->getTableName('catalog_product_entity') . " WHERE entity_id = ?"; $count = $connection->fetchOne($sql, array($id)); if($count > 0){ return true; }else{ return false; } } private function getTableName($tableName){ return Mage::getSingleton('core/resource')->getTableName($tableName); } private function getAttributeId($attribute_code){ $connection = $this->getConnection('core_read'); $sql = "SELECT attribute_id FROM " .$this->getTableName('eav_attribute') . " WHERE entity_type_id = ? AND attribute_code = ?"; $entity_type_id = $this->getEntityTypeId(); return $connection->fetchOne($sql, array($entity_type_id, $attribute_code)); } private function getConnection($type = 'core_read'){ return Mage::getSingleton('core/resource')->getConnection($type); } private function getEntityTypeId($entity_type_code = 'catalog_product'){ $connection = $this->getConnection('core_read'); $sql = "SELECT entity_type_id FROM " . $this->getTableName('eav_entity_type') . " WHERE entity_type_code = ?"; return $connection->fetchOne($sql, array($entity_type_code)); }
0 0
- sql的方式修改产品属性 - 避免使用event (magento)
- Magento 修改添加产品的默认属性值
- magento sql 获取指定产品的指定属性值
- Magento 中产品属性筛选器的使用
- [Magento SQL]查询出可配置产品(父产品)、子产品的价格,和与子产品对应属性的差价
- 给分类添加一个属性,模块sql的方式 -- magento
- magento -- 获取产品的属性值
- 如何去掉magento产品的系统属性
- magento -- 列表页显示产品属性值的几种调用方式
- magento 列表页显示产品属性值的几种调用方式
- magento 列表页显示产品属性值的几种调用方式
- magento如何改变产品的排序方式
- magento 的特色产品获取方式
- magento:如何改变产品的排序方式
- 修改magento产品列表页每行显示的产品个数
- magento 使用 sales_order_place_after event
- magento -- 根据属性名获得产品的属性值
- Magento,sql,setup的方式添加一个select属性,add attribute selet by module sql
- Android 游戏开发笔记一、入门之SurfaceView的使用
- log4j各配制项详解
- IE9中X-UA-Compatible失效的问题与值: 对象为 null 或未定义
- iOS网络编程之Socket
- 【转】JavaScript中Date.parse 函数用法
- sql的方式修改产品属性 - 避免使用event (magento)
- XMPPFramework环境配置
- android JNI学习五
- 详解 “预处理、编译(compile)、 代码优化、 汇编(Assembly)、 链接 (link)”的具体过程
- Linux常用命令
- IOS开发中17个常用代码整理
- 学习笔记——WPF
- Android WatchDog正解
- 海量数据面试题目