更换新产品以在主页pestashop上显示所有产品

时间:2016-02-15 03:18:47

标签: prestashop prestashop-1.6

我想使用此功能更改新产品以在主页上显示所有产品:

Product::getProducts((int) $this->context->language->id, 0,0, 'id_product', 'DESC', 0);

原始功能是:

$newProducts = Product::getNewProducts((int) $this->context->language->id, 0);

我在product-list.tpl模板文件中显示此数据。

但是当我使用Product::getProducts()函数时,显示的products数组是这样的:

array (size=61)
  'id_product' => string '32' (length=2)
  'id_supplier' => string '10' (length=2)
  'id_manufacturer' => string '0' (length=1)
  'id_category_default' => string '2' (length=1)
  'id_shop_default' => string '1' (length=1)
  'id_tax_rules_group' => string '1' (length=1)
  'on_sale' => string '0' (length=1)
  'online_only' => string '0' (length=1)
  'ean13' => string '' (length=0)
  'upc' => string '' (length=0)
  'ecotax' => string '0.000000' (length=8)
  'quantity' => string '0' (length=1)
  'minimal_quantity' => string '1' (length=1)
  'price' => string '174.900000' (length=10)
  'wholesale_price' => string '0.000000' (length=8)
  'unity' => string '' (length=0)
  'unit_price_ratio' => string '0.000000' (length=8)
  'additional_shipping_cost' => string '0.00' (length=4)
  'reference' => string '' (length=0)
  'supplier_reference' => string '' (length=0)
  'location' => string '' (length=0)
  'width' => string '0.000000' (length=8)
  'height' => string '0.000000' (length=8)
  'depth' => string '0.000000' (length=8)
  'weight' => string '0.000000' (length=8)
  'out_of_stock' => string '2' (length=1)
  'quantity_discount' => string '0' (length=1)
  'customizable' => string '0' (length=1)
  'uploadable_files' => string '0' (length=1)
  'text_fields' => string '0' (length=1)
  'active' => string '1' (length=1)
  'redirect_type' => string '' (length=0)
  'id_product_redirected' => string '0' (length=1)
  'available_for_order' => string '1' (length=1)
  'available_date' => string '0000-00-00' (length=10)
  'condition' => string 'new' (length=3)
  'show_price' => string '1' (length=1)
  'indexed' => string '0' (length=1)
  'visibility' => string 'both' (length=4)
  'cache_is_pack' => string '0' (length=1)
  'cache_has_attachments' => string '0' (length=1)
  'is_virtual' => string '0' (length=1)
  'cache_default_attribute' => string '0' (length=1)
  'date_add' => string '2016-02-10 03:20:06' (length=19)
  'date_upd' => string '2016-02-10 03:20:30' (length=19)
  'advanced_stock_management' => string '0' (length=1)
  'id_shop' => string '1' (length=1)
  'id_lang' => string '1' (length=1)
  'description' => string '<p><span> LEGO Mos Eisley Cantina</span></p><p><span>Age 8-14</span></p><p><span><br /></span></p><p><span>Recreate iconic Star Wars scenes at Mos Eisley Cantina™!</span></p><p><span>Welcome to the noisy and dangerous Mos Eisley Cantina™ on the desert world of Tatooine! Park the landspeeder and enter, staying clear of the giant dewback drinking from the trough outside. Make sure Luke, Han and Obi-Wan have their weapons with them as they enter through the sliding door and walk past the droid scanner. Op'... (length=2342)
  'description_short' => string '' (length=0)
  'link_rewrite' => string 'lego-75052' (length=10)
  'meta_description' => string '' (length=0)
  'meta_keywords' => string '' (length=0)
  'meta_title' => string '' (length=0)
  'name' => string 'LEGO 75052' (length=10)
  'available_now' => string '' (length=0)
  'available_later' => string '' (length=0)
  'manufacturer_name' => null
  'supplier_name' => string 'Kids World' (length=10)
  'rate' => float 0
  'tax_name' => string '' (length=0)

使用Product::getNewProducts()函数,显示的products数组如下:

array (size=80)
  'id_product' => string '30' (length=2)
  'id_supplier' => string '10' (length=2)
  'id_manufacturer' => string '0' (length=1)
  'id_category_default' => string '2' (length=1)
  'id_shop_default' => string '1' (length=1)
  'id_tax_rules_group' => string '1' (length=1)
  'on_sale' => string '0' (length=1)
  'online_only' => string '0' (length=1)
  'ean13' => string '' (length=0)
  'upc' => string '' (length=0)
  'ecotax' => string '0.000000' (length=8)
  'quantity' => int 1
  'minimal_quantity' => string '1' (length=1)
  'price' => float 172.9
  'wholesale_price' => string '0.000000' (length=8)
  'unity' => string '' (length=0)
  'unit_price_ratio' => string '0.000000' (length=8)
  'additional_shipping_cost' => string '0.00' (length=4)
  'reference' => string '' (length=0)
  'supplier_reference' => string '' (length=0)
  'location' => string '' (length=0)
  'width' => string '0.000000' (length=8)
  'height' => string '0.000000' (length=8)
  'depth' => string '0.000000' (length=8)
  'weight' => string '0.000000' (length=8)
  'out_of_stock' => string '0' (length=1)
  'quantity_discount' => string '0' (length=1)
  'customizable' => string '0' (length=1)
  'uploadable_files' => string '0' (length=1)
  'text_fields' => string '0' (length=1)
  'active' => string '1' (length=1)
  'redirect_type' => string '' (length=0)
  'id_product_redirected' => string '0' (length=1)
  'available_for_order' => string '1' (length=1)
  'available_date' => string '0000-00-00' (length=10)
  'condition' => string 'new' (length=3)
  'show_price' => string '1' (length=1)
  'indexed' => string '0' (length=1)
  'visibility' => string 'both' (length=4)
  'cache_is_pack' => string '0' (length=1)
  'cache_has_attachments' => string '0' (length=1)
  'is_virtual' => string '0' (length=1)
  'cache_default_attribute' => string '0' (length=1)
  'date_add' => string '2016-02-10 03:20:06' (length=19)
  'date_upd' => string '2016-02-10 03:20:17' (length=19)
  'advanced_stock_management' => string '0' (length=1)
  'id_shop' => string '1' (length=1)
  'description' => string '<p><span>LEGO Super Secret Police Dr</span></p><p><span>Age 9-14</span></p><p><span>Pursue Emmet and the Master Builders in the awesome Dropship!</span></p><p><span>Lord Business’ Robo Police have invaded Cloud Cuckoo Land in their high-tech Dropship and are in hot pursuit of Emmet, Batman™, Green Ninja and Johnny Thunder! With a pair of Robo SWATs at the controls in the dual cockpit, fire up the rocket boosters for lift-off. Once airborne, turn the rear control to rotate the boosters and surge forward '... (length=2259)
  'description_short' => string '' (length=0)
  'link_rewrite' => string 'lego-70815' (length=10)
  'meta_description' => string '' (length=0)
  'meta_keywords' => string '' (length=0)
  'meta_title' => string '' (length=0)
  'name' => string 'LEGO 70815' (length=10)
  'available_now' => string '' (length=0)
  'available_later' => string '' (length=0)
  'id_image' => string '30-367' (length=6)
  'legend' => string '' (length=0)
  'manufacturer_name' => null
  'new' => string '1' (length=1)
  'product_attribute_minimal_quantity' => null
  'id_product_attribute' => string '0' (length=1)
  'allow_oosp' => int 0
  'category' => string 'home' (length=4)
  'link' => string 'http://192.168.120.9/shop168.com/index.php?id_product=30&controller=product&id_lang=1' (length=85)
  'attribute_price' => int 0
  'price_tax_exc' => float 172.9
  'price_without_reduction' => float 172.9
  'reduction' => float 0
  'specific_prices' => 
    array (size=0)
      empty
  'quantity_all_versions' => int 1
  'features' => 
    array (size=0)
      empty
  'attachments' => 
    array (size=0)
      empty
  'virtual' => int 0
  'pack' => int 0
  'packItems' => 
    array (size=0)
      empty
  'nopackprice' => int 0
  'customization_required' => boolean false
  'rate' => float 0
  'tax_name' => string '' (length=0)

如果我使用Product::getProducts()函数,我可以获得61个数组值,但是当我使用Product::getNewProducts()函数时,我可以获得80个数组值。 那么如何使用Product::getProducts()函数获得80个数组值?

3 个答案:

答案 0 :(得分:0)

这是功能

getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false,
    $only_active = false, Context $context = null)

如果您使用:

Product::getProducts($id_lang, 0, 80, 'id_product', 'ASC');

应该有效

答案 1 :(得分:0)

如果你看一下这两种方法,你会发现getNewProducts也有每种产品的属性,所以

$products = Product::getProducts($this->context->language->id, 0, 0, 'id_product', 'DESC', 0);
$products_with_properties = Product::getProductsProperties($this->context->language->id, $products);

$products_with_properties将包含具有所有属性的产品(原始问题解释中包含80多个数组元素)

答案 2 :(得分:-1)

继续使用getNewProducts并将第3个参数设置为1000

$newProducts = Product::getNewProducts((int) $this->context->language->id, 0, 1000);