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


PHP Product::getPrice方法代码示例

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


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

示例1: assignPriceAndTax

 /**
  * Assign price and tax to the template.
  */
 protected function assignPriceAndTax()
 {
     $id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
     $id_group = (int) Group::getCurrent()->id;
     $id_country = $id_customer ? (int) Customer::getCurrentCountry($id_customer) : (int) Tools::getCountry();
     // Tax
     $tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
     $this->context->smarty->assign('tax_rate', $tax);
     $product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6);
     if (Product::$_taxCalculationMethod == PS_TAX_INC) {
         $product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
     }
     $id_currency = (int) $this->context->cookie->id_currency;
     $id_product = (int) $this->product->id;
     $id_product_attribute = Tools::getValue('id_product_attribute', null);
     $id_shop = $this->context->shop->id;
     $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_product_attribute, false, (int) $this->context->customer->id);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount['id_product_attribute']) {
             $combination = new Combination((int) $quantity_discount['id_product_attribute']);
             $attributes = $combination->getAttributesName((int) $this->context->language->id);
             foreach ($attributes as $attribute) {
                 $quantity_discount['attributes'] = $attribute['name'] . ' - ';
             }
             $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
         }
         if ((int) $quantity_discount['id_currency'] == 0 && $quantity_discount['reduction_type'] == 'amount') {
             $quantity_discount['reduction'] = Tools::convertPriceFull($quantity_discount['reduction'], null, Context::getContext()->currency);
         }
     }
     $product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
     $this->quantity_discounts = $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax, $this->product->ecotax);
     $this->context->smarty->assign(array('no_tax' => Tax::excludeTaxeOption() || !$tax, 'tax_enabled' => Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC'), 'customer_group_without_tax' => Group::getPriceDisplayMethod($this->context->customer->id_default_group)));
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:37,代码来源:ProductController.php

示例2: __construct

 /**
  * public __construct
  *
  * @description initialise our checkout
  */
 public function __construct(&$product)
 {
     // If we are being created then there is only 1 of us
     parent::__construct($product->getCode(), $product->getName(), $product->getPrice());
     $this->quantity = 1;
     $this->totalPrice = parent::getPrice();
 }
开发者ID:KidsOnShred,项目名称:dc-test,代码行数:12,代码来源:CheckoutItem.class.php

示例3: addToTotal

 public function addToTotal(Product $product)
 {
     // if(!is_null($product))
     // {
     // 	$this->total += $product->getPrice();
     // }
     $this->total += $product->getPrice();
 }
开发者ID:elagith,项目名称:learningMaterial,代码行数:8,代码来源:Receipt.php

示例4: compute

 function compute(Product $product)
 {
     $discountProvider = DiscountProvider::getInstance();
     $discountAsPercent = $discountProvider->getDiscountFor($product->getId());
     $price = $product->getPrice();
     $discountAsValue = $price * $discountAsPercent / 100;
     return $price - $discountAsValue;
 }
开发者ID:anggadarkprince,项目名称:design-pattern,代码行数:8,代码来源:PriceCalculator.php

示例5: getPrice

 public function getPrice()
 {
     $price = parent::getPrice();
     if ($this->expire <= 10) {
         $price /= 2;
     }
     return $price;
 }
开发者ID:yinm,项目名称:yinm.github.io,代码行数:8,代码来源:index.php

示例6: create

 public static function create(Product $oProduct)
 {
     $oCartProduct = new CartProduct();
     $oCartProduct->setImage($oProduct->getImage());
     $oCartProduct->setId($oProduct->getId());
     $oCartProduct->setDescription($oProduct->getDescription());
     $oCartProduct->setName($oProduct->getName());
     $oCartProduct->setPrice($oProduct->getPrice());
     return $oCartProduct;
 }
开发者ID:benjamincargnino,项目名称:ecommerce,代码行数:10,代码来源:CartProduct.class.php

示例7: add

 public function add(Product $toBeAdded)
 {
     $stmt = $this->database->prepare("INSERT INTO  `store`.`Products` (\n\t\t\t`pk` , `title` , `description` , `price` )\n\t\t\t\tVALUES (?, ?, ?, ?)");
     if ($stmt === FALSE) {
         throw new \Exception($this->database->error);
     }
     $pk = $toBeAdded->getUniqueString();
     $title = $toBeAdded->getTitle();
     $description = $toBeAdded->getDescription();
     $price = $toBeAdded->getPrice();
     $stmt->bind_param('sssd', $pk, $title, $description, $price);
     $stmt->execute();
 }
开发者ID:henceee,项目名称:1DV608,代码行数:13,代码来源:ProductDAL.php

示例8: productAddStore

 /**
  * Hozzá adja, elmenti az adatbázisban az új termék adatait.
  *
  * @param Product $product
  * @return Exception|string
  */
 public function productAddStore($product)
 {
     //die("temrék neve: " . $product->getName());
     if ($this->checkProductExist($product->getName()) === FALSE) {
         try {
             self::$conn->preparedInsert("termekek", array("nev", "kat_azon", "kisz_azon", "suly", "egysegar", "min_keszlet", "min_rend", "kim_azon", "akcio", "reszletek", "kep"), array($product->getName(), $product->getCategory(), $product->getPackage(), $product->getWeight(), $product->getPrice(), $product->getMinStock(), $product->getMinOrder(), $product->getHighlight(), $product->getDiscount(), $product->getDescription(), $product->getImg()));
             //die("Sql után!");
         } catch (Exception $e) {
             return new Exception("Nem sikerült elmenteni a terméket!");
         }
         //$stmt = $conn->preparedQuery("SELECT t_azon FROM termekek WHERE nev=?",array("$name"));
         return "Sikeres termék felvitel!";
     } else {
         return "Létezik már ilyen termék!";
     }
 }
开发者ID:kubu1518,项目名称:rftCandyShop,代码行数:22,代码来源:UserAsLeader.php

示例9: getVariants

 private function getVariants()
 {
     $groups = array();
     if ($this->combinations && count($this->combinations)) {
         foreach ($this->combinations as $combination) {
             if (!array_key_exists($combination['id_product_attribute'], $groups)) {
                 $groups[$combination['id_product_attribute']] = array('code' => PowatagProductAttributeHelper::getVariantCode($combination), 'numberInStock' => PowaTagProductQuantityHelper::getCombinationQuantity($combination), 'productImages' => $this->getCombinationImages($combination['id_product_attribute']), 'originalPrice' => array('amount' => $this->formatNumber($this->product->getPrice($this->display_taxes, null), 2), 'currency' => $this->context->currency->iso_code), 'finalPrice' => array('amount' => $this->formatNumber($this->product->getPrice($this->display_taxes, $combination['id_product_attribute']), 2), 'currency' => $this->context->currency->iso_code));
             }
             $groups[$combination['id_product_attribute']]['options'][$combination['group_name']] = $combination['attribute_name'];
         }
         sort($groups);
     } else {
         $variant = array('code' => PowaTagProductHelper::getProductSKU($this->product), 'numberInStock' => PowaTagProductQuantityHelper::getProductQuantity($this->product), 'finalPrice' => array('amount' => $this->formatNumber($this->product->getPrice($this->display_taxes, null), 2), 'currency' => $this->context->currency->iso_code));
         $groups = array($variant);
     }
     return $groups;
 }
开发者ID:powa,项目名称:prestashop-extension,代码行数:17,代码来源:PowaTagProduct.php

示例10: testChildProduct

 public function testChildProduct()
 {
     $this->product->setPrice($this->usd, 20);
     $this->product->shippingWeight->set(200);
     $this->product->save();
     $child = $this->product->createChildProduct();
     $root = Category::getRootNode();
     $root->reload();
     $productCount = $root->totalProductCount->get();
     // in array representation, parent product data is used where own data is not set
     $array = $child->toArray();
     $this->assertEquals($array['name_en'], $this->product->getValueByLang('name', 'en'));
     // auto-generated SKU is based on parent SKU
     $child->save();
     $this->assertEquals($child->sku->get(), $this->product->sku->get() . '-1');
     // category counters should not change
     $root->reload();
     $this->assertEquals($root->totalProductCount->get(), $productCount);
     // parent product price used if not defined
     $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd));
     // parent shipping weight used if not defined
     $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight());
     // add/substract parent prices/shipping weights
     $child->setChildSetting('test', 'value');
     $this->assertEquals($child->getChildSetting('test'), 'value');
     // prices
     $child->setChildSetting('price', Product::CHILD_ADD);
     $child->setPrice($this->usd, 5);
     $this->assertEquals(20, $this->product->getPrice($this->usd));
     $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd) + 5);
     $child->setChildSetting('price', Product::CHILD_SUBSTRACT);
     $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd) - 5);
     $child->setChildSetting('price', Product::CHILD_OVERRIDE);
     $this->assertEquals($child->getPrice($this->usd), 5);
     // shipping weight
     $child->setChildSetting('weight', Product::CHILD_ADD);
     $child->shippingWeight->set(5);
     $this->assertEquals(200, $this->product->getShippingWeight());
     $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight() + 5);
     $child->setChildSetting('weight', Product::CHILD_SUBSTRACT);
     $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight() - 5);
     $child->setChildSetting('weight', Product::CHILD_OVERRIDE);
     $this->assertEquals($child->getShippingWeight(), 5);
 }
开发者ID:saiber,项目名称:livecart,代码行数:44,代码来源:ProductTest.php

示例11: assignPriceAndTax

 /**
  * Assign price and tax to the template
  */
 protected function assignPriceAndTax()
 {
     $id_customer = isset($this->context->customer) ? (int) $this->context->customer->id : 0;
     $id_group = isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_;
     $id_country = (int) $id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT');
     $group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
     if ($group_reduction == 0) {
         $group_reduction = Group::getReduction((int) $this->context->cookie->id_customer) / 100;
     }
     // Tax
     $tax = (double) $this->product->getTaxesRate(new Address((int) $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
     $this->context->smarty->assign('tax_rate', $tax);
     $product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6);
     if (Product::$_taxCalculationMethod == PS_TAX_INC) {
         $product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
     }
     $product_price_without_eco_tax = (double) $product_price_with_tax - $this->product->ecotax;
     $ecotax_rate = (double) Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
     if (Product::$_taxCalculationMethod == PS_TAX_INC && (int) Configuration::get('PS_TAX')) {
         $ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
     }
     $id_currency = (int) $this->context->cookie->id_currency;
     $id_product = (int) $this->product->id;
     $id_shop = $this->context->shop->id;
     $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true);
     foreach ($quantity_discounts as &$quantity_discount) {
         if ($quantity_discount['id_product_attribute']) {
             $combination = new Combination((int) $quantity_discount['id_product_attribute']);
             $attributes = $combination->getAttributesName((int) $this->context->language->id);
             foreach ($attributes as $attribute) {
                 $quantity_discount['attributes'] = $attribute['name'] . ' - ';
             }
             $quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
         }
     }
     $product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
     $address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     $this->context->smarty->assign(array('quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (double) $tax), 'ecotax_tax_inc' => $ecotax_tax_amount, 'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2), 'ecotaxTax_rate' => $ecotax_rate, 'productPriceWithoutEcoTax' => (double) $product_price_without_eco_tax, 'group_reduction' => 1 - $group_reduction, 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address), 'ecotax' => !count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((double) $this->product->ecotax) : 0, 'tax_enabled' => Configuration::get('PS_TAX')));
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:43,代码来源:ProductController.php

示例12: create

 public function create(SubCategory $sub_category, $name, $description, $price, $img, $stock)
 {
     $errors = array();
     $product = new Product($this->db);
     try {
         $product->setSubCategory($sub_category);
         $product->setName($name);
         $product->setDescription($description);
         $product->setPrice($price);
         $product->setImg($img);
         $product->setStock($stock);
     } catch (Exception $e) {
         $errors[] = $e->getMessage();
     }
     $errors = array_filter($errors, function ($val) {
         return $val !== true;
     });
     if (count($errors) == 0) {
         $idSubCategory = intval($product->getIdSubCategory());
         $name = $this->db->quote($product->getName());
         $description = $this->db->quote($product->getDescription());
         $price = $this->db->quote($product->getPrice());
         $img = $this->db->quote($product->getImg());
         $stock = $this->db->quote($product->getStock());
         $query = "INSERT INTO product(id_sub_category, name, description, price, img, stock) VALUES('" . $idSub_category . "', " . $name . ", " . $description . ", " . $price . ", " . $img . ", " . $stock . ")";
         $res = $this->db->exec($query);
         if ($res) {
             $id = $this->db->lastInsertId();
             if ($id) {
                 return $this->findById($id);
             } else {
                 return "Internal Server error";
             }
         }
     } else {
         return $errors;
     }
 }
开发者ID:berserkr1,项目名称:e-commerce,代码行数:38,代码来源:ProductManager.class.php

示例13: CheckoutButton

 /**
  *   Get the form variables for the purchase button.
  *
  *   @uses   PaymentGw::_Supports()
  *   @uses   _encButton()
  *   @uses   getActionUrl()
  *   @return string      HTML for purchase button
  */
 public function CheckoutButton($cart)
 {
     global $_PP_CONF, $_USER, $_TABLES;
     if (!$this->_Supports('checkout')) {
         return '';
     }
     $cartItems = $cart->Cart();
     $cartID = $cart->CartID();
     $custom_arr = array('uid' => $_USER['uid'], 'transtype' => 'cart_upload', 'cart_id' => $cartID);
     $fields = array('cmd' => '_cart', 'upload' => '1', 'cancel_return' => PAYPAL_URL . '/index.php?view=cart', 'return' => PAYPAL_URL . '/index.php?thanks=paypal', 'rm' => '2', 'paymentaction' => 'sale', 'notify_url' => $this->ipn_url, 'currency_code' => $this->currency_code, 'custom' => str_replace('"', '\'', serialize($custom_arr)));
     $address = $cart->getAddress('shipto');
     if (!empty($address)) {
         list($fname, $lname) = explode(' ', $address['name']);
         $fields['first_name'] = htmlspecialchars($fname);
         $fields['last_name'] = htmlspecialchars($lname);
         $fields['address1'] = htmlspecialchars($address['address1']);
         $fields['address2'] = htmlspecialchars($address['address2']);
         $fields['city'] = htmlspecialchars($address['city']);
         $fields['state'] = htmlspecialchars($address['state']);
         $fields['country'] = htmlspecialchars($address['country']);
         $fields['zip'] = htmlspecialchars($address['zip']);
     }
     $i = 1;
     $total_amount = 0;
     $shipping = 0;
     $weight = 0;
     foreach ($cartItems as $cart_item_id => $item) {
         //$opt_str = '';
         list($db_item_id, $options) = explode('|', $item['item_id']);
         if (is_numeric($db_item_id)) {
             $P = new Product($db_item_id);
             $db_item_id = DB_escapeString($db_item_id);
             $oc = 0;
             if (is_array($item['options'])) {
                 $opts = explode(',', $options);
                 foreach ($opts as $optval) {
                     $opt_info = $P->getOption($optval);
                     if ($opt_info) {
                         $opt_str .= ', ' . $opt_info['value'];
                         $fields['on' . $oc . '_' . $i] = $opt_info['name'];
                         $fields['os' . $oc . '_' . $i] = $opt_info['value'];
                         $oc++;
                     }
                 }
                 //$item['descrip'] .= $opt_str;
             } else {
                 $opts = array();
             }
             $fields['amount_' . $i] = $P->getPrice($opts, $item['quantity']);
             if ($P->taxable == 0) {
                 $fields['tax_' . $i] = '0.00';
             }
         } else {
             // Plugin item
             $fields['amount_' . $i] = $item['price'];
         }
         //$fields['item_number_' . $i] = htmlspecialchars($item['item_id']);
         $fields['item_number_' . $i] = (int) $cart_item_id;
         $fields['item_name_' . $i] = htmlspecialchars($item['descrip']);
         $total_amount += $item['price'];
         if (is_array($item['extras']['custom'])) {
             foreach ($item['extras']['custom'] as $id => $val) {
                 $fields['on' . $oc . '_' . $i] = $P->getCustom($id);
                 $fields['os' . $oc . '_' . $i] = $val;
                 $oc++;
             }
         }
         $fields['quantity_' . $i] = $item['quantity'];
         if (isset($item['shipping'])) {
             $fields['shipping_' . $i] = $item['shipping'];
             $shipping += $item['shipping'];
         }
         if (isset($item['weight']) && $item['weight'] > 0) {
             $weight += $item['weight'];
         }
         if (isset($item['tax'])) {
             $fields['tax_' . $i] = $item['tax'];
         } elseif (isset($item['options']['tax'])) {
             $fields['tax_' . $i] = $item['options']['tax'];
         }
         $i++;
     }
     if ($shipping > 0) {
         $total_amount += $shipping;
     }
     if ($weight > 0) {
         $fields['weight_cart'] = $weight;
         $fields['weight_unit'] = $_PP_CONF['weight_unit'] == 'kgs' ? 'kgs' : 'lbs';
     }
     // Set the business e-mail address based on the total puchase amount
     // There must be an address configured; if not then this gateway can't
     // be used for this purchase
//.........这里部分代码省略.........
开发者ID:JohnToro,项目名称:paypal,代码行数:101,代码来源:paypal.class.php

示例14: displayProducts

    public function displayProducts()
    {
        global $currentIndex, $cookie;
        if (isset($this->_list['obj'])) {
            $nbProducts = sizeof($this->_list['obj']);
            echo '<h3>' . $this->_list['message'] . ' ' . $nbProducts . ' ' . $this->l('found') . '</h3>';
            if (!$nbProducts) {
                return;
            }
            $this->fieldsDisplay = array('ID' => array('title' => $this->l('ID')), 'manufacturer' => array('title' => $this->l('Manufacturer')), 'reference' => array('title' => $this->l('Reference')), 'name' => array('title' => $this->l('Name')), 'price' => array('title' => $this->l('Price')), 'tax' => array('title' => $this->l('Tax')), 'stock' => array('title' => $this->l('Stock')), 'weight' => array('title' => $this->l('Weight')), 'status' => array('title' => $this->l('Status')), 'action' => array('title' => $this->l('Actions')));
            $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
            echo '
			<table class="table" cellpadding="0" cellspacing="0">
				<tr>';
            foreach ($this->fieldsDisplay as $field) {
                echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>';
            }
            echo '
				</tr>';
            foreach ($this->_list['obj'] as $k => $prod) {
                $product = new Product(intval($prod['id_product']));
                $product->name = $product->name[intval($cookie->id_lang)];
                $tax = new Tax(intval($product->id_tax));
                echo '
				<tr>
					<td>' . $product->id . '</td>
					<td align="center">' . ($product->manufacturer_name != NULL ? stripslashes($product->manufacturer_name) : '--') . '</td>
					<td>' . $product->reference . '</td>
					<td><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '">' . stripslashes($product->name) . '</a></td>
					<td>' . Tools::displayPrice($product->getPrice(), $currency) . '</td>
					<td>' . stripslashes($tax->name[intval($cookie->id_lang)]) . '</td>
					<td align="center">' . $product->quantity . '</td>
					<td align="center">' . $product->weight . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</td>
					<td align="center"><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&status&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '"><img src="../img/admin/' . ($product->active ? 'enabled.gif' : 'disabled.gif') . '" alt="" /></a></td>
					<td>
						<a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '">
						<img src="../img/admin/edit.gif" alt="' . $this->l('Modify this product') . '" /></a>&nbsp;
						<a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . addslashes($this->l('Do you want to delete') . ' ' . $product->name) . ' ?\');">
						<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" /></a>
					</td>
				</tr>';
            }
            echo '</table><br /><br />';
        }
    }
开发者ID:sealence,项目名称:local,代码行数:45,代码来源:AdminTracking.php

示例15: generateProductsData

    protected function generateProductsData()
    {
        $delimiter = ';';
        $titles = array();
        $id_lang = $this->use_lang;
        $new_path = new Sampledatainstall();
        $f = fopen($new_path->sendPath() . 'output/products.vsc', 'w');
        foreach ($this->product_fields as $field => $array) {
            $titles[] = $array['label'];
        }
        fputcsv($f, $titles, $delimiter, '"');
        $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', false, true);
        foreach ($products as $product) {
            $line = array();
            $p = new Product($product['id_product'], true, $id_lang, 1);
            foreach ($this->product_fields as $field => $array) {
                $line[$field] = property_exists('Product', $field) && !is_array($p->{$field}) && !Tools::isEmpty($p->{$field}) ? $p->{$field} : '';
            }
            $cats = $p->getProductCategoriesFull($p->id, 1);
            $cat_array = array();
            foreach ($cats as $cat) {
                $cat_array[] = $cat['id_category'];
            }
            $line['categories'] = implode(',', $cat_array);
            $line['price_tex'] = $p->getPrice(false);
            $line['price_tin'] = $p->getPrice(true);
            $line['upc'] = $p->upc ? $p->upc : '';
            $line['features'] = '';
            $features = $p->getFrontFeatures($id_lang);
            $position = 1;
            $devider = '';
            foreach ($features as $feature) {
                $sql = 'SELECT `id_feature`
						FROM ' . _DB_PREFIX_ . 'feature_lang
						WHERE `name` = "' . pSql($feature['name']) . '"';
                $sql1 = 'SELECT `id_feature_value`
						FROM ' . _DB_PREFIX_ . 'feature_value_lang
						WHERE `value` = "' . pSql($feature['value']) . '"';
                $id_feature = Db::getInstance()->getValue($sql);
                $id_feature_value = Db::getInstance()->getValue($sql1);
                $line['features'] .= $devider . $id_feature . ':' . $id_feature_value . ':' . $position;
                $devider = ',';
                $position++;
            }
            $specificPrice = SpecificPrice::getSpecificPrice($p->id, 1, 0, 0, 0, 0);
            $line['reduction_price'] = '';
            $line['reduction_percent'] = '';
            $line['reduction_from'] = '';
            $line['reduction_to'] = '';
            if ($specificPrice) {
                if ($specificPrice['reduction_type'] == 'amount') {
                    $line['reduction_price'] = $specificPrice['reduction'];
                } elseif ($specificPrice['reduction_type'] == 'percent') {
                    $line['reduction_percent'] = $specificPrice['reduction'];
                }
                if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
                    $line['reduction_from'] = $specificPrice['from'];
                    $line['reduction_to'] = $specificPrice['to'];
                }
            }
            $tags = $p->getTags($id_lang);
            $line['tags'] = $tags;
            $link = new Link();
            $imagelinks = array();
            $images = $p->getImages($id_lang);
            foreach ($images as $image) {
                $imagelink = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
                $this->copyConverFileName($imagelink);
                $imagelinks[] = $imagelink;
            }
            $line['image'] = implode(',', $imagelinks);
            $line['delete_existing_images'] = 0;
            $line['shop'] = 1;
            $warehouses = Warehouse::getWarehousesByProductId($p->id);
            $line['warehouse'] = '';
            if (!empty($warehouses)) {
                $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
            }
            $values = array();
            $accesories = $p->getAccessories($id_lang);
            if (isset($accesories) && $accesories && count($accesories)) {
                foreach ($accesories as $accesorie) {
                    $values[] = $accesorie['id_product'];
                }
            }
            $line['accessories'] = $values ? implode(',', $values) : '';
            $values = array();
            $carriers = $p->getCarriers();
            if (isset($carriers) && $carriers && count($carriers)) {
                foreach ($carriers as $carrier) {
                    $values[] = $carrier['id_carrier'];
                }
            }
            $line['carriers'] = $values ? implode(',', $values) : '';
            $values = array();
            $customization_fields_ids = $p->getCustomizationFieldIds();
            if (class_exists('CustomizationField') && isset($customization_fields_ids) && $customization_fields_ids && count($customization_fields_ids)) {
                foreach ($customization_fields_ids as $customization_field_id) {
                    $cf = new CustomizationField($customization_field_id['id_customization_field'], $this->use_lang);
                    $values[] = $cf->id . ':' . $cf->type . ':' . $cf->required . ':' . $cf->name;
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:AdminSampleDataInstallExport.php


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