2016-02-15 1 views
1

изменить новые продукты, чтобы отобразить все продукты на домашней странице pestashop

Я хочу изменить новые продукты, чтобы отобразить весь продукт на домашней странице с помощью этой функции:

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() функцию, массив продуктов показано, как это:

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() функцию, массив продуктов показано, как это:

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 значений массива. Так как я могу получить 80 значений массива, используя функцию Product::getProducts()?

+0

Благодарности теперь работает я измените его на эту функцию '$ category = new Category (Context :: getContext() -> shop-> getCategory(), (int) Context :: getContext() -> language-> id); return $ products = $ category-> getProducts ((int) Context :: getContext() -> language-> id, ($ st? $ St: 0), ($ nb? $ Nb: 100), 'id_product' , 'DESC'); ' –

ответ

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'); 

Он должен работать

+0

Спасибо, теперь я могу изменить его на эту функцию' $ category = new Category (Context :: getContext() -> shop-> getCategory(), (int) Context :: getContext() - > language-> ID); return $ products = $ category-> getProducts ((int) Context :: getContext() -> language-> id, ($ st? $ St: 0), ($ nb? $ Nb: 100), 'id_product' , 'DESC'); ' –

+0

Рад помочь, если вы можете пометить ответ как правильно – Matteo

+0

Но я не уверен, что все ответы верны или нет, потому что я использую мой код. –

-1

Keep с помощью getNewProducts и установить 3-ий параметров до 1000

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

если вы посмотрите в этих 2 методов вы увидите, что 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+ элементы массива в оригинальной интерпретации вопроса)