Carlostlr Posted January 21, 2020 Share Posted January 21, 2020 Buenas, gracias de antemano. Estoy desarrollando un modulo en el cual se podrá indicar hasta 20 productos de forma manual para mostrarlos en la portada. El problema que tengo es que al recuperar la información del producto aparecen muchos campos en blanco o con isUnsignedId. Este es mi código: $id_product = 10474; $anyproduct = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); $images = $anyproduct->getImages($this->context->language->id); $list_image = array(); foreach ($images as $img) { $image['cover'] = (bool)$img['cover']; $image['url'] = $this->context->link->getImageLink($anyproduct->link_rewrite, $img['id_image'], 'home_default'); $image['position'] = $img['position']; array_push($list_image,$image); } var_dump($anyproduct); Con esto obtengo la imagen y los datos del producto, el array devuelto es el siguiente: object(Product)[354] public 'tax_name' => string 'deprecated' (length=10) public 'tax_rate' => float 21 public 'id_manufacturer' => string '94' (length=2) public 'id_supplier' => string '0' (length=1) public 'id_category_default' => string '108' (length=3) public 'id_shop_default' => string '1' (length=1) public 'manufacturer_name' => string 'Xiaomi' (length=6) public 'supplier_name' => boolean false public 'name' => string 'Smartphone XIAOMI REDMI 8A - Azul, 32GB/2GB, 6.2", Octa-Core, 4G' (length=64) public 'description' => string '' (length=0) public 'description_short' => string '<p>- Cámara trasera de 12MP dual pixel + 8MP (selfie).</p> <p>- Potente procesador Octa-core Qualcomm Snapdragon 439</p> <p>- Sistema operativo Android 9 con MIUI 10</p> <p>- Pantalla HD+ de 1560x720 pixeles</p>' (length=216) public 'quantity' => int 28 public 'minimal_quantity' => string '1' (length=1) public 'low_stock_threshold' => null public 'low_stock_alert' => string '0' (length=1) public 'available_now' => string '' (length=0) public 'available_later' => string '' (length=0) public 'price' => float 90.823278 public 'specificPrice' => array (size=19) 'id_specific_price' => string '1465488' (length=7) 'id_specific_price_rule' => string '0' (length=1) 'id_cart' => string '0' (length=1) 'id_product' => string '10474' (length=5) 'id_shop' => string '1' (length=1) 'id_shop_group' => string '0' (length=1) 'id_currency' => string '0' (length=1) 'id_country' => string '0' (length=1) 'id_group' => string '1' (length=1) 'id_customer' => string '0' (length=1) 'id_product_attribute' => string '0' (length=1) 'price' => string '-1.000000' (length=9) 'from_quantity' => string '1' (length=1) 'reduction' => string '0.120100' (length=8) 'reduction_tax' => string '1' (length=1) 'reduction_type' => string 'percentage' (length=10) 'from' => string '0000-00-00 00:00:00' (length=19) 'to' => string '0000-00-00 00:00:00' (length=19) 'score' => string '50' (length=2) public 'additional_shipping_cost' => string '0.00' (length=4) public 'wholesale_price' => string '0.000000' (length=8) public 'on_sale' => string '0' (length=1) public 'online_only' => string '0' (length=1) public 'unity' => string '' (length=0) public 'unit_price' => int 0 public 'unit_price_ratio' => string '0.000000' (length=8) public 'ecotax' => string '0.000000' (length=8) public 'reference' => string '0000989735' (length=10) public 'supplier_reference' => string '' (length=0) public 'location' => string '' (length=0) public 'width' => string '0.000000' (length=8) public 'height' => string '0.000000' (length=8) public 'depth' => string '0.000000' (length=8) public 'weight' => string '0.000000' (length=8) public 'ean13' => string '6941059630623' (length=13) public 'isbn' => string '' (length=0) public 'upc' => string '' (length=0) public 'link_rewrite' => string 'smartphone-xiaomi-redmi-8a-azul-32gb2gb-62-octa-core-4g' (length=55) public 'meta_description' => string '' (length=0) public 'meta_keywords' => string '' (length=0) public 'meta_title' => string '' (length=0) public 'quantity_discount' => string '0' (length=1) public 'customizable' => string '0' (length=1) public 'new' => boolean false public 'uploadable_files' => string '0' (length=1) public 'text_fields' => string '0' (length=1) public 'active' => string '1' (length=1) public 'redirect_type' => string '404' (length=3) public 'id_type_redirected' => string '0' (length=1) public 'available_for_order' => string '1' (length=1) public 'available_date' => string '0000-00-00' (length=10) public 'show_condition' => string '1' (length=1) public 'condition' => string 'new' (length=3) public 'show_price' => string '1' (length=1) public 'indexed' => string '1' (length=1) public 'visibility' => string 'both' (length=4) public 'date_add' => string '2019-11-06 15:17:03' (length=19) public 'date_upd' => string '2019-11-20 17:07:19' (length=19) public 'tags' => boolean false public 'state' => string '1' (length=1) public 'base_price' => string '103.220000' (length=10) public 'id_tax_rules_group' => string '1' (length=1) public 'id_color_default' => int 0 public 'advanced_stock_management' => string '0' (length=1) public 'out_of_stock' => int 0 public 'depends_on_stock' => boolean false public 'isFullyLoaded' => boolean true public 'cache_is_pack' => string '0' (length=1) public 'cache_has_attachments' => string '0' (length=1) public 'is_virtual' => string '0' (length=1) public 'id_pack_product_attribute' => null public 'cache_default_attribute' => string '0' (length=1) public 'category' => string 'smartphones' (length=11) public 'pack_stock_type' => string '3' (length=1) public 'additional_delivery_times' => string '1' (length=1) public 'delivery_in_stock' => string '' (length=0) public 'delivery_out_stock' => string '' (length=0) protected 'webserviceParameters' => array (size=4) 'objectMethods' => array (size=2) 'add' => string 'addWs' (length=5) 'update' => string 'updateWs' (length=8) 'objectNodeNames' => string 'products' (length=8) 'fields' => array (size=12) 'id_manufacturer' => array (size=1) ... 'id_supplier' => array (size=1) ... 'id_category_default' => array (size=1) ... 'new' => array (size=0) ... 'cache_default_attribute' => array (size=0) ... 'id_default_image' => array (size=3) ... 'id_default_combination' => array (size=3) ... 'id_tax_rules_group' => array (size=1) ... 'position_in_category' => array (size=2) ... 'manufacturer_name' => array (size=2) ... 'quantity' => array (size=2) ... 'type' => array (size=2) ... 'associations' => array (size=9) 'categories' => array (size=2) ... 'images' => array (size=2) ... 'combinations' => array (size=2) ... 'product_option_values' => array (size=2) ... 'product_features' => array (size=2) ... 'tags' => array (size=2) ... 'stock_availables' => array (size=3) ... 'accessories' => array (size=3) ... 'product_bundle' => array (size=3) ... public 'id' => int 10474 protected 'id_lang' => int 1 protected 'id_shop' => int 1 public 'id_shop_list' => null protected 'get_shop_from_context' => boolean false protected 'table' => string 'product' (length=7) protected 'identifier' => string 'id_product' (length=10) protected 'fieldsRequired' => array (size=1) 0 => string 'price' (length=5) protected 'fieldsSize' => array (size=6) 'reference' => int 32 'supplier_reference' => int 32 'location' => int 64 'ean13' => int 13 'isbn' => int 32 'upc' => int 12 protected 'fieldsValidate' => array (size=48) 'id_shop_default' => string 'isUnsignedId' (length=12) 'id_manufacturer' => string 'isUnsignedId' (length=12) 'id_supplier' => string 'isUnsignedId' (length=12) 'reference' => string 'isReference' (length=11) 'supplier_reference' => string 'isReference' (length=11) 'location' => string 'isReference' (length=11) 'width' => string 'isUnsignedFloat' (length=15) 'height' => string 'isUnsignedFloat' (length=15) 'depth' => string 'isUnsignedFloat' (length=15) 'weight' => string 'isUnsignedFloat' (length=15) 'quantity_discount' => string 'isBool' (length=6) 'ean13' => string 'isEan13' (length=7) 'isbn' => string 'isIsbn' (length=6) 'upc' => string 'isUpc' (length=5) 'cache_is_pack' => string 'isBool' (length=6) 'cache_has_attachments' => string 'isBool' (length=6) 'is_virtual' => string 'isBool' (length=6) 'state' => string 'isUnsignedId' (length=12) 'additional_delivery_times' => string 'isUnsignedId' (length=12) 'id_category_default' => string 'isUnsignedId' (length=12) 'id_tax_rules_group' => string 'isUnsignedId' (length=12) 'on_sale' => string 'isBool' (length=6) 'online_only' => string 'isBool' (length=6) 'ecotax' => string 'isPrice' (length=7) 'minimal_quantity' => string 'isUnsignedInt' (length=13) 'low_stock_threshold' => string 'isInt' (length=5) 'low_stock_alert' => string 'isBool' (length=6) 'price' => string 'isPrice' (length=7) 'wholesale_price' => string 'isPrice' (length=7) 'unity' => string 'isString' (length=8) 'additional_shipping_cost' => string 'isPrice' (length=7) 'customizable' => string 'isUnsignedInt' (length=13) 'text_fields' => string 'isUnsignedInt' (length=13) 'uploadable_files' => string 'isUnsignedInt' (length=13) 'active' => string 'isBool' (length=6) 'redirect_type' => string 'isString' (length=8) 'id_type_redirected' => string 'isUnsignedId' (length=12) 'available_for_order' => string 'isBool' (length=6) 'available_date' => string 'isDateFormat' (length=12) 'show_condition' => string 'isBool' (length=6) 'condition' => string 'isGenericName' (length=13) 'show_price' => string 'isBool' (length=6) 'indexed' => string 'isBool' (length=6) 'visibility' => string 'isProductVisibility' (length=19) 'advanced_stock_management' => string 'isBool' (length=6) 'date_add' => string 'isDate' (length=6) 'date_upd' => string 'isDate' (length=6) 'pack_stock_type' => string 'isUnsignedInt' (length=13) protected 'fieldsRequiredLang' => array (size=0) empty protected 'fieldsSizeLang' => array (size=9) 'delivery_in_stock' => int 255 'delivery_out_stock' => int 255 'meta_description' => int 255 'meta_keywords' => int 255 'meta_title' => int 128 'link_rewrite' => int 128 'name' => int 128 'available_now' => int 255 'available_later' => int 255 protected 'fieldsValidateLang' => array (size=11) 'delivery_in_stock' => string 'isGenericName' (length=13) 'delivery_out_stock' => string 'isGenericName' (length=13) 'meta_description' => string 'isGenericName' (length=13) 'meta_keywords' => string 'isGenericName' (length=13) 'meta_title' => string 'isGenericName' (length=13) 'link_rewrite' => string 'isLinkRewrite' (length=13) 'name' => string 'isCatalogName' (length=13) 'description' => string 'isCleanHtml' (length=11) 'description_short' => string 'isCleanHtml' (length=11) 'available_now' => string 'isGenericName' (length=13) 'available_later' => string 'IsGenericName' (length=13) protected 'tables' => array (size=0) empty protected 'image_dir' => null protected 'image_format' => string 'jpg' (length=3) protected 'translator' => null protected 'def' => array (size=7) 'table' => string 'product' (length=7) 'primary' => string 'id_product' (length=10) 'multilang' => boolean true 'multilang_shop' => boolean true 'fields' => array (size=61) 'id_shop_default' => array (size=2) ... 'id_manufacturer' => array (size=2) ... 'id_supplier' => array (size=2) ... 'reference' => array (size=3) ... 'supplier_reference' => array (size=3) ... 'location' => array (size=3) ... 'width' => array (size=2) ... 'height' => array (size=2) ... 'depth' => array (size=2) ... 'weight' => array (size=2) ... 'quantity_discount' => array (size=2) ... 'ean13' => array (size=3) ... 'isbn' => array (size=3) ... 'upc' => array (size=3) ... 'cache_is_pack' => array (size=2) ... 'cache_has_attachments' => array (size=2) ... 'is_virtual' => array (size=2) ... 'state' => array (size=2) ... 'additional_delivery_times' => array (size=2) ... 'delivery_in_stock' => array (size=4) ... 'delivery_out_stock' => array (size=4) ... 'id_category_default' => array (size=3) ... 'id_tax_rules_group' => array (size=3) ... 'on_sale' => array (size=3) ... 'online_only' => array (size=3) ... 'ecotax' => array (size=3) ... 'minimal_quantity' => array (size=3) ... 'low_stock_threshold' => array (size=4) ... 'low_stock_alert' => array (size=4) ... 'price' => array (size=4) ... 'wholesale_price' => array (size=3) ... 'unity' => array (size=3) ... 'unit_price_ratio' => array (size=2) ... 'additional_shipping_cost' => array (size=3) ... 'customizable' => array (size=3) ... 'text_fields' => array (size=3) ... 'uploadable_files' => array (size=3) ... 'active' => array (size=3) ... 'redirect_type' => array (size=3) ... 'id_type_redirected' => array (size=3) ... 'available_for_order' => array (size=3) ... 'available_date' => array (size=3) ... 'show_condition' => array (size=3) ... 'condition' => array (size=5) ... 'show_price' => array (size=3) ... 'indexed' => array (size=3) ... 'visibility' => array (size=5) ... 'cache_default_attribute' => array (size=2) ... 'advanced_stock_management' => array (size=3) ... 'date_add' => array (size=3) ... 'date_upd' => array (size=3) ... 'pack_stock_type' => array (size=3) ... 'meta_description' => array (size=4) ... 'meta_keywords' => array (size=4) ... 'meta_title' => array (size=4) ... 'link_rewrite' => array (size=6) ... 'name' => array (size=5) ... 'description' => array (size=3) ... 'description_short' => array (size=3) ... 'available_now' => array (size=4) ... 'available_later' => array (size=4) ... 'associations' => array (size=7) 'manufacturer' => array (size=1) ... 'supplier' => array (size=1) ... 'default_category' => array (size=3) ... 'tax_rules_group' => array (size=1) ... 'categories' => array (size=4) ... 'stock_availables' => array (size=4) ... 'l' => array (size=3) ... 'classname' => string 'Product' (length=7) protected 'update_fields' => null public 'force_id' => boolean false Cómo hago para que me devuelva todos los datos del artículo 1 Link to comment Share on other sites More sharing options...
ventura Posted January 21, 2020 Share Posted January 21, 2020 En módulos propios de Prestashop tienes ejemplos de como hacerlo utilizando sus propias funciones, solamente necesitarías un parámetro asociativo para generar un array con esos productos y toda su información Link to comment Share on other sites More sharing options...
Carlostlr Posted January 21, 2020 Author Share Posted January 21, 2020 @ventura Gracias por la respuesta, he estado viendo varios módulos pero en casi todos obtiene los datos del producto que está cargado actualmente. Lo que yo quiero es poder pasarle un id de un producto, el cual cambiará cada X tiempo y solo consigo que me devuelva los datos que he puesto antes. Link to comment Share on other sites More sharing options...
Carlostlr Posted January 27, 2020 Author Share Posted January 27, 2020 Nadie puede ayudarme? no consigo encontrar la forma de hacerlo. Necesito ayuda por favor Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now