magento 检测 订单号, 是否真的存在/ sales/order_item 表进行查找 里面所有字段
来源:互联网 发布:linux系统安装软件 编辑:程序博客网 时间:2024/06/06 13:57
/* $order = Core::getModel('sales/order');$orderItems = $order->getItemsCollection()->addAttributeToSelect('*')->addAttributeToFilter('product_type', array('eq'=>'simple'));print_r($orderItems);die; */ 这是对 sales/order_item 表进行查找 里面所有字段$orderItems = Core::getModel('sales/order_item')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('product_type', array('eq'=>'simple'));//print_r($orderItems);die;foreach($orderItems as $sItem) { if($sItem->getProductType() == "simple") { //print_r($sItem);die(); //echo "\n*********************************\nCore Order #: ".$OrderNumber."\n"; //Simple Item Info from Order echo "<pre>"; echo "Type: ".$sItem->getProductType()."\n"; echo "Order Id: ".$sItem->getOrderId()."\n"; echo "Product Id: ".$sItem->getProductId()."\n"; echo "Item Id: ".$sItem->getId()."\n"; echo "Item Name: ".$sItem->getName()."\n"; echo "Item Sku: ".$sItem->getSku()."\n"; echo "Item Price: ".$sItem->getPrice()."\n"; $pItemId = $sItem->getParentItemId(); echo "Parent Item Id: ".$pItemId."\n"; echo "\n*****\n"; //Get Parent Item Information $item = Core::getModel('sales/order_item')->load("$pItemId"); //use an item_id here //Testing, want to see whats inside the parent/configurable item? //print_r($item->toArray()); echo "Parent Type: ".$item->getProductType()."\n"; echo "Parent Order Id: ".$item->getOrderId()."\n"; echo "Product Id: ".$item->getProductId()."\n"; echo "Item Id: ".$item->getId()."\n"; echo "Parent Item Price: ".$item->getPrice()."\n"; echo "Qty: ".$qty = intval($item->getQtyOrdered())."\n"; //get Active Product Data $nProduct = Core::getModel('catalog/product')->load($sItem->getProductId()); $nSku = $nProduct->getSku(); echo "new Product UPC:".$nUpc = $nProduct->getUpc() . "\n"; echo "new Product Price:".$nPrice = $nProduct->getPrice(). "\n"; echo '......................................................................'; }}以下是做个简单测试,,检测 订单号, 是否真的存在。。。。<pre style="" class="default prettyprint prettyprinted"><code><span class="pln">$collection </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Mage</span><span class="pun">::</span><span class="pln">getModel</span><span class="pun">(</span><span class="str">'sales/order'</span><span class="pun">)-></span><span class="pln">getCollection</span><span class="pun">()-></span><span class="pln">addFieldToFilter</span><span class="pun">(</span><span class="str">'increment_id'</span><span class="pun">,</span><span class="pln"> $reservedOrderId</span><span class="pun">);</span><span class="pln"></span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$collection</span><span class="pun">-></span><span class="pln">count</span><span class="pun">())</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="com">// order already exists</span><span class="pln"></span><span class="pun">}</span></code>
$increment_id = '100000002';$order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);if($order->getIncrementId() == $increment_id){ var_dump("Increment IDs match, that means there's an order");}else{ var_dump("Increment IDs don't match, that means there's no order");}
$increment_id = '100000002';$order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);if($order->getData()){ var_dump("Data array means there's an order");}else{ var_dump("Empty data array means there's no order");}
$increment_id = '100000002';$c = Mage::getModel('sales/order')->getCollection() ->addFieldToFilter('increment_id',$increment_id); if(count($c) > 0){ var_dump("A collection with more than zero items means the order exists");}else{ var_dump("An empty collection means it does not");}
0 0
- magento 检测 订单号, 是否真的存在/ sales/order_item 表进行查找 里面所有字段
- mysql 查找数据库里面字段的id是否存在 可以限定表和字段
- 查找整个数据库里面包含某一字段的所有表
- sql中查找表名和字段是否存在
- sqlite查看所有表名及字段名,及判断是否存在的方法
- sqlite查看所有表名及字段名,及判断是否存在的方法
- sqlite查看所有表名及字段名,及判断是否存在的方法
- sqlite查看所有表名、判断表是否存在,字段名及字段信息
- Android检测表是否存在
- 读取指定文件夹里面的所有图片取出里面其中一张图片和判断文件夹或文件是否存在
- C++ Json中检测某个字段是否存在的方url法
- SQL查找表是否存在
- 在当前数据库的所有表,所有字段查找字符串
- 查询某字段所存在的所有表
- 查询某字段所存在的所有表
- oracle检索出存在指定字段的所有表
- android 检测sqlite数据表中字段(列)是否存在
- android 检测sqlite数据表中字段(列)是否存在
- 无聊写排序之 ---- 希尔排序(ShellSort)
- 配置redhat yum源
- maven3常用命令
- SSO服务在云端为身份认证保驾护航
- 将QT程序设为ARM板开机自行启动的方法
- magento 检测 订单号, 是否真的存在/ sales/order_item 表进行查找 里面所有字段
- duilib 的IE浏览器控件去边框和去滚动条的代码
- Linux设置全局环境变量的三种方法
- 打开页面从数据库读出数据显示到页面上的解决方法
- 黑马程序员---Foundation常用类练习(计算文件代码行数)
- Android 实用工具网络篇(一)
- Quick(lua) 中解析Xml
- 上海java软件工程师的工资待遇
- 关联、组合、聚合、依赖关系比较