当前位置: 首页>>代码示例>>PHP>>正文


PHP PrestaShopCollection::getAll方法代码示例

本文整理汇总了PHP中PrestaShopCollection::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP PrestaShopCollection::getAll方法的具体用法?PHP PrestaShopCollection::getAll怎么用?PHP PrestaShopCollection::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PrestaShopCollection的用法示例。


在下文中一共展示了PrestaShopCollection::getAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderCSV

 /**
  * Exports CSV
  */
 protected function renderCSV()
 {
     // exports orders
     if (Tools::isSubmit('csv_orders')) {
         $ids = array();
         foreach ($this->_list as $entry) {
             $ids[] = $entry['id_supply_order'];
         }
         if (count($ids) <= 0) {
             return;
         }
         $id_lang = Context::getContext()->language->id;
         $orders = new PrestaShopCollection('SupplyOrder', $id_lang);
         $orders->where('is_template', '=', false);
         $orders->where('id_supply_order', 'in', $ids);
         $id_warehouse = $this->getCurrentWarehouse();
         if ($id_warehouse != -1) {
             $orders->where('id_warehouse', '=', $id_warehouse);
         }
         $orders->getAll();
         $csv = new CSV($orders, $this->l('supply_orders'));
         $csv->export();
     } elseif (Tools::isSubmit('csv_orders_details')) {
         // header
         header('Content-type: text/csv');
         header('Content-Type: application/force-download; charset=UTF-8');
         header('Cache-Control: no-store, no-cache');
         header('Content-disposition: attachment; filename="' . $this->l('supply_orders_details') . '.csv"');
         // echoes details
         $ids = array();
         foreach ($this->_list as $entry) {
             $ids[] = $entry['id_supply_order'];
         }
         if (count($ids) <= 0) {
             return;
         }
         // for each supply order
         $keys = array('id_product', 'id_product_attribute', 'reference', 'supplier_reference', 'ean13', 'upc', 'name', 'unit_price_te', 'quantity_expected', 'quantity_received', 'price_te', 'discount_rate', 'discount_value_te', 'price_with_discount_te', 'tax_rate', 'tax_value', 'price_ti', 'tax_value_with_order_discount', 'price_with_order_discount_te', 'id_supply_order');
         echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $keys)));
         // overrides keys (in order to add FORMAT calls)
         $keys = array('sod.id_product', 'sod.id_product_attribute', 'sod.reference', 'sod.supplier_reference', 'sod.ean13', 'sod.upc', 'sod.name', 'FORMAT(sod.unit_price_te, 2)', 'sod.quantity_expected', 'sod.quantity_received', 'FORMAT(sod.price_te, 2)', 'FORMAT(sod.discount_rate, 2)', 'FORMAT(sod.discount_value_te, 2)', 'FORMAT(sod.price_with_discount_te, 2)', 'FORMAT(sod.tax_rate, 2)', 'FORMAT(sod.tax_value, 2)', 'FORMAT(sod.price_ti, 2)', 'FORMAT(sod.tax_value_with_order_discount, 2)', 'FORMAT(sod.price_with_order_discount_te, 2)', 'sod.id_supply_order');
         foreach ($ids as $id) {
             $query = new DbQuery();
             $query->select(implode(', ', $keys));
             $query->from('supply_order_detail', 'sod');
             $query->leftJoin('supply_order', 'so', 'so.id_supply_order = sod.id_supply_order');
             $id_warehouse = $this->getCurrentWarehouse();
             if ($id_warehouse != -1) {
                 $query->where('so.id_warehouse = ' . (int) $id_warehouse);
             }
             $query->where('sod.id_supply_order = ' . (int) $id);
             $query->orderBy('sod.id_supply_order_detail DESC');
             $resource = Db::getInstance()->query($query);
             // gets details
             while ($row = Db::getInstance()->nextRow($resource)) {
                 echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
             }
         }
     } elseif (Tools::isSubmit('csv_order_details') && Tools::getValue('id_supply_order')) {
         $supply_order = new SupplyOrder((int) Tools::getValue('id_supply_order'));
         if (Validate::isLoadedObject($supply_order)) {
             $details = $supply_order->getEntriesCollection();
             $details->getAll();
             $csv = new CSV($details, $this->l('supply_order') . '_' . $supply_order->reference . '_details');
             $csv->export();
         }
     }
 }
开发者ID:zangles,项目名称:lennyba,代码行数:71,代码来源:AdminSupplyOrdersController.php


注:本文中的PrestaShopCollection::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。