magento 获取产品存货量以及configurable product 下associated children product信息
Magento – Get Product Stock Quantity
To get the quantity in stock for a particular product in Magento use the following code -
$qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty();
来源:http://www.codeboss.in/web-funda/2011/03/03/magento-get-product-stock-quantity/
Magento: How to get all associated children product of a configurable product?
Here is the code to fetch all the children products that are associated with a configurable product.
Here goes the code :)
/*** Load product by product id*/
$product = Mage::getModel('catalog/product')->load(YOUR_PRODUCT_ID);/*** Get child products id (only ids)
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());/*** Get children products (all associated children products data)*/
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
来源: http://blog.chapagain.com.np/magento-how-to-get-all-associated-children-product-of-a-configurable-product/
实例1:
Get Configurable Product (or) Associated Product details in Magento Product page
In this post, I’ll explain about how to get Configurable/associated/grouped product details in Magento product page?
//Note: In the below code if there is any ` (bactics) symbol, replace it to single quotes. $conf_pro = Mage::getModel('catalog/product')->load($_product->getId());
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$conf_pro); //print_r($childProducts); // Print and see the array indexes and fetch details according to your requirement
foreach($childProducts as $child) { echo $child['name'];} //Get the configurable attribute name of the product in product view page:$configurable = $_product->getTypeInstance();
$attributes = $configurable->getConfigurableAttributes($_product);
foreach ($attributes as $attribute) {print $attribute->getLabel();print "<br />";
}
实例2:
<?php $_product = $this->getProduct(); ?>
<?php
$children = array();
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product);
foreach($childProducts as $child):$qty = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($child)->getQty();$size = $child->getResource()->getAttribute('size')->getFrontend()->getValue($child);$children[$size]['title'] = $child->getName();$children[$size]['size'] = $size;$children[$size]['qty'] = $qty;
endforeach;echo '<pre>'; print_r($children); echo '</pre>'; die;
?>
magento 获取产品存货量以及configurable product 下associated children product信息相关推荐
- Magento: 获取产品评论 get all reviews with review summary
1. 根据产品id获取该产品评论 $productId = 1234; $product = Mage::getModel('catalog/product')->load($productId ...
- Magento获取产品自定义属性及对应的值
自定义产品属性后,通常可以设置其是否在产品查看页中显示,可显属性将会出现在additional information 中.但是这边我需要在分类列表页中调用产品特定的属性. 在列表页循环获取对应产品的 ...
- magento 获取产品的属性值
magento采用强大的EAV设计方法,我们可以很方便的给商品添加任意数量的属性,那如何在前台获取这些属性值呢? magento同样提供了很方便的方式来读取它.使用$_product->getA ...
- magento -- 获取产品的属性值
magento采用强大的EAV设计方法,我们可以很方便的给商品添加任意数量的属性,那如何在前台获取这些属性值呢?magento同样提供了很方便的方式来读取它.使用$_product->getAt ...
- Magento 获取有效属性 Display available options for attributes of Configurable
1. 获取全部 //get Product $cProduct = Mage::getModel('catalog/product')->load($_product->getId()); ...
- magento 根据产品id,获取产品信息
假设产品的id 存在变量$id中 那么 $_product = Mage::getModel('catalog/product')->load($id); 打印数据信息: var_dump($_ ...
- Magento: 单产品(product)或者当前类别(category)最大和最小价格 Min/Max Product Price in a Category...
1. 当前类别最大最小价格: $minPrice = Mage::getModel('catalog/product')->getCollection()->addStoreFilter( ...
- textfield获取其中内容_用户认知视角下的产品信息获取体验度量体系研究
文 / 张凯 孙宁娜 崔学伟 ( 南京艺术学院 工业设计学院:江苏大学 艺术学院 ) DOI编码:10.3969/J.ISSN.1674-4187.2020.03.006 摘要:从用户认知视角出发,结 ...
- magento 获取自定义产品属性和属性值
在magento系统中经常要自定义自己的产品属性,在后台自定义的产品属性如何获取呢,下面根据属性类型的不同分别说明 产品属性要想在前台获取到需要设置属性的Used in Product Listing ...
最新文章
- telegraf监控mysql数据库_influxdb+grafana+telegraf 监听性能数据 (完整详细版)
- Netty 4.1 Getting Start (翻译) + Demo
- farbox editor是个好东西
- Python的10大最佳功能是什么?
- Python学习:集合
- 用 Python 读写 Excel 表格,就是这么的简单粗暴且乏味
- querywrapper 时间区间查询_雅思官方:关于增设用于英国签证及移民的雅思考试考点的通知!附20192020雅思考试时间安排...
- 51单片机的轮胎气压监测系统_汽车的胎压监测系统有哪些作用?
- python的核心理念是什么_Python 面向对象编程的核心概念知识点简介
- python内容目标_python抓取一个页面的目标网址,然后抓取目标网址里的内容
- linux下nand flash驱动工作原理,1.3.4. Nand flash驱动工作原理
- Linux下通过WebShell反弹Shell的技巧
- Performing User-Managed Database-18.4、Restoring Datafiles and Archived Redo Logs
- php商城拍卖逻辑,thinkphp商城购物车逻辑思路
- CPU工作方式、多核心、超线程技术详解[转贴]
- Eigen内存分配器aligned_allocator
- SMAA算法详解 - SMAANeighborhoodBlendingPS
- c语言switch有什么作用,c语言switch语句如何使用
- Lua实现三目运算符
- Java架构师视频+授课资料
热门文章
- 2的幂次方表示(信息学奥赛一本通-T1208)
- 44 SD配置-销售凭证设置-定义状态参数文件
- 4.6.1 定义工作区
- iis网站服务器响应慢,IIS响应慢
- tplink 2.4g弱信号剔除_科普 l 路由器信号2.4G和5G区别
- Kubesphere V2.1.1安装后开启可拔插组件DevOps(2)
- OpenCV中基本数据结构(6)_Matx
- 注意力公式步骤每一步的含义,总共三步
- MaskRCNN要点
- 小程序 长按api_微信小程序API相关知识科普