Jump to content

Stéphane1405

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • First Name
    Stéphane
  • Last Name
    Richard

Stéphane1405's Achievements

Newbie

Newbie (1/14)

4

Reputation

1

Community Answers

  1. again, thanks for you time yaniv. using $category = new Category($id_category) I still get the notice plus a new one "Array to string conversion" with echo $category->name that did not return error before.
  2. thanks yaniv, from Category.php : public function getName($id_lang = null) { if (!$id_lang) { if (isset($this->name[Context::getContext()->language->id])) $id_lang = Context::getContext()->language->id; else $id_lang = (int)Configuration::get('PS_LANG_DEFAULT'); } return isset($this->name[$id_lang]) ? $this->name[$id_lang] : ''; }
  3. thanks yaniv, echo $category->getName(1) gives the same result as echo $category->getName(); it returns one letter.
  4. Thanks yaniv for your time. Unfortunately the name of the category is not 'o' :-( I haved added getName() and var_dump ($category) here is my code and HTML output. PHP code <?php define('PRESTASHOP_S_EXTERNAL_SCRIPT', true); include(dirname(__FILE__).'\..\prestashop_1.6.1.0\prestashop\config\config.inc.php'); echo Configuration::get('PS_LANG_DEFAULT'); echo "<br/>"; $id_category = 117; $category = new Category($id_category, (int)Configuration::get('PS_LANG_DEFAULT'),(int)Configuration::get('PS_SHOP_DEFAULT')); //works echo $category->name; echo "<br/>"; //returns just one letter echo $category->getName(1); echo "<br/>"; //returns the correct number bu with PHP notice echo $category->getProducts(1,1,1000,null,null,1,1); echo " products<br/>"; var_dump($category); HTML output 1 right category name a ( ! ) Notice: Trying to get property of non-object in C:\wamp\www\NBS\preprod\prestashop_1.6.1.0\prestashop\classes\Category.php on line 671 Call Stack #TimeMemoryFunctionLocation 10.0007250160{main}( )..\presta_desactive_cat_vides.php:0 20.096612154384CategoryCore->getProducts( )..\presta_desactive_cat_vides.php:36 8 products object(Category)[20] public 'id' => int 117 public 'id_category' => string '117' (length=3) public 'name' => string 'Haut Médoc' (length=11) public 'active' => string '1' (length=1) public 'position' => string '25' (length=2) public 'description' => string '' (length=0) public 'id_parent' => string '36' (length=2) public 'id_category_default' => null public 'level_depth' => string '4' (length=1) public 'nleft' => string '55' (length=2) public 'nright' => string '56' (length=2) public 'link_rewrite' => string 'haut-medoc' (length=10) public 'meta_title' => string '' (length=0) public 'meta_keywords' => string '' (length=0) public 'meta_description' => string '' (length=0) public 'date_add' => string '2016-01-06 20:29'... (length=19) public 'date_upd' => string '2016-01-06 20:29'... (length=19) public 'is_root_category' => string '0' (length=1) public 'id_shop_default' => string '1' (length=1) public 'groupBox' => null public 'id_image' => boolean false protected 'webserviceParameters' => array (size=4) 'objectsNodeName' => string 'categories' (length=10) 'hidden_fields' => array (size=3) 0 => string 'nleft' (length=5) 1 => string 'nright' (length=6) 2 => string 'groupBox' (length=8) 'fields' => array (size=3) 'id_parent' => array (size=1) 'xlink_resource' => string 'categories' (length=10) 'level_depth' => array (size=1) 'setter' => boolean false 'nb_products_recursive' => array (size=2) 'getter' => string 'getWsNbProductsR'... (length=24) 'setter' => boolean false 'associations' => array (size=2) 'categories' => array (size=2) 'getter' => string 'getChildrenWs' (length=13) 'resource' => string 'category' (length=8) 'products' => array (size=2) 'getter' => string 'getProductsWs' (length=13) 'resource' => string 'product' (length=7) 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 'category' (length=8) protected 'identifier' => string 'id_category' (length=11) protected 'fieldsRequired' => array (size=1) 0 => string 'active' (length=6) protected 'fieldsSize' => array (size=0) empty protected 'fieldsValidate' => array (size=9) 'nleft' => string 'isUnsignedInt' (length=13) 'nright' => string 'isUnsignedInt' (length=13) 'level_depth' => string 'isUnsignedInt' (length=13) 'active' => string 'isBool' (length=6) 'id_parent' => string 'isUnsignedInt' (length=13) 'id_shop_default' => string 'isUnsignedId' (length=12) 'is_root_category' => string 'isBool' (length=6) 'date_add' => string 'isDate' (length=6) 'date_upd' => string 'isDate' (length=6) protected 'fieldsRequiredLang' => array (size=2) 0 => string 'name' (length=4) 1 => string 'link_rewrite' (length=12) protected 'fieldsSizeLang' => array (size=5) 'name' => int 128 'link_rewrite' => int 128 'meta_title' => int 128 'meta_description' => int 255 'meta_keywords' => int 255 protected 'fieldsValidateLang' => array (size=6) 'name' => string 'isCatalogName' (length=13) 'link_rewrite' => string 'isLinkRewrite' (length=13) 'description' => string 'isCleanHtml' (length=11) 'meta_title' => string 'isGenericName' (length=13) 'meta_description' => string 'isGenericName' (length=13) 'meta_keywords' => string 'isGenericName' (length=13) protected 'tables' => array (size=0) empty protected 'image_dir' => string 'C:\wamp\www\NBS\'... (length=60) protected 'image_format' => string 'jpg' (length=3) protected 'def' => array (size=7) 'table' => string 'category' (length=8) 'primary' => string 'id_category' (length=11) 'multilang' => boolean true 'multilang_shop' => boolean true 'fields' => array (size=16) 'nleft' => array (size=2) 'type' => int 1 'validate' => string 'isUnsignedInt' (length=13) 'nright' => array (size=2) 'type' => int 1 'validate' => string 'isUnsignedInt' (length=13) 'level_depth' => array (size=2) 'type' => int 1 'validate' => string 'isUnsignedInt' (length=13) 'active' => array (size=3) 'type' => int 2 'validate' => string 'isBool' (length=6) 'required' => boolean true 'id_parent' => array (size=2) 'type' => int 1 'validate' => string 'isUnsignedInt' (length=13) 'id_shop_default' => array (size=2) 'type' => int 1 'validate' => string 'isUnsignedId' (length=12) 'is_root_category' => array (size=2) 'type' => int 2 'validate' => string 'isBool' (length=6) 'position' => array (size=1) 'type' => int 1 'date_add' => array (size=2) 'type' => int 5 'validate' => string 'isDate' (length=6) 'date_upd' => array (size=2) 'type' => int 5 'validate' => string 'isDate' (length=6) 'name' => array (size=5) 'type' => int 3 'lang' => boolean true 'validate' => string 'isCatalogName' (length=13) 'required' => boolean true 'size' => int 128 'link_rewrite' => array (size=5) 'type' => int 3 'lang' => boolean true 'validate' => string 'isLinkRewrite' (length=13) 'required' => boolean true 'size' => int 128 'description' => array (size=3) 'type' => int 6 'lang' => boolean true 'validate' => string 'isCleanHtml' (length=11) 'meta_title' => array (size=4) 'type' => int 3 'lang' => boolean true 'validate' => string 'isGenericName' (length=13) 'size' => int 128 'meta_description' => array (size=4) 'type' => int 3 'lang' => boolean true 'validate' => string 'isGenericName' (length=13) 'size' => int 255 'meta_keywords' => array (size=4) 'type' => int 3 'lang' => boolean true 'validate' => string 'isGenericName' (length=13) 'size' => int 255 'classname' => string 'Category' (length=8) 'associations' => array (size=1) 'l' => array (size=3) 'type' => int 2 'field' => string 'id_category' (length=11) 'foreign_field' => string 'id_category' (length=11) protected 'update_fields' => null public 'force_id' => boolean false I hope somebody will have an idea.
  5. Thanks a lot for your precise answer. I tried what you suggested and I still get the notice. I also have a problem with the getName() property that returns just 1 letter : define('PRESTASHOP_S_EXTERNAL_SCRIPT', true); include(dirname(__FILE__).'\..\prestashop_1.6.1.0\prestashop\config\config.inc.php'); echo Configuration::get('PS_LANG_DEFAULT'); echo "<br/>"; $id_category = 123; $category = new Category($id_category, (int)Configuration::get('PS_LANG_DEFAULT'),(int)Configuration::get('PS_SHOP_DEFAULT')); //that works echo $category->name; echo "<br/>"; //returns one letter echo $category->getName(1); echo "<br/>"; //returns number of products but with PHP notice echo $category->getProducts(1,1,1000,null,null,1,1); echo "<br/>"; returns 1 category name a ( ! ) Notice: Trying to get property of non-object in prestashop_1.6.1.0\prestashop\classes\Category.php on line 671 Call Stack # Time Memory Function Location 1 0.0006 248448 {main}( ) ..\presta_desactive_cat_vides.php:0 2 0.0962 12152432 CategoryCore->getProducts( ) ..\presta_desactive_cat_vides.php:34 8 Any suggestion would be greatly appreciated.
  6. Hello everyone, Here is my code : define('PRESTASHOP_S_EXTERNAL_SCRIPT', true); include(dirname(__FILE__).'\..\prestashop_1.6.1.0\prestashop\config\config.inc.php'); echo Configuration::get('PS_LANG_DEFAULT'); $id_category = 123; $category = new Category($id_category, Configuration::get('PS_LANG_DEFAULT')); //product count echo $category->getProducts(1,1,1000,null,null,1,1); I get the default language id , the number of products of category 123 but in between I get a notice "trying to get property of non objet" even though PHP is_object($category) returns TRUE. Here is the screen I get : I have got not clue, so your help will be greatly appreciated. Thanks for reading, Stéphane
  7. Hello world, I would like to get all products ids of products having a specific feature, I did not find a way to do it with getProducts(). Exemple : get all products whose style is classic. Any idea ? Cheers, Stéphane
  8. The following script will create a new cart rule that can for instance be used for coupon code (voucher). This is drawn from cart rule object model definition (classes/CartRule.php L78). $coupon = new Discount(); //put here the coupon name + translations //ex: if your website is in french (id language = 1) and english (id language = 2) $coupon->name = array(1=>"mon coupon",2=>"my coupon"); //by default cart rule is valid for one client that can use it one time //validity $coupon->date_from = "2015-08-20"; $coupon->date_to = "2015-08-21"; //code $coupon->code = "789456"; //50 % off $coupon->reduction_percent = "50"; //conditions //ex: rule only applies if the order is 100 or more including taxes and exluding shipping $coupon->minimum_amount = 100; $coupon->minimum_amount_tax = 1; $coupon->minimum_amount_currency = 1; $coupon->minimum_amount_shipping = 0; //this creates the coupon $coupon->add(); Hope this will help
  9. I eventually found the answer. On your external script, use a constant ex: PRESTASHOP_EXTERNAL_SCRIPT external_script.php define('PRESTASHOP_EXTERNAL_SCRIPT', true); include(dirname(__FILE__).'/../prestashop/config/config.inc.php'); then on prestashop/classes/shop/shop.php add the following BELOW (L401) // Hmm there is something really bad in your Prestashop ! if (!Validate::isLoadedObject($default_shop)) throw new PrestaShopException('Shop not found'); ADD if (defined('PRESTASHOP_EXTERNAL_SCRIPT')) { $shop = $default_shop; } else { AND below (L441) header('HTTP/1.0 '.$redirect_code.' '.$redirect_header); header('Location: http://'.$url); exit; ADD } Hope this will help.
  10. Hello, I have got one Prestashop and one Wordpress running on the same machine. I'm trying to use Prestashop order class in Wordpress . I have included prestashop\config\config.inc.php and prestashop\init.php in my Wordpress script but it redirects Wordpress on Prestashop. Any help would be greatly appreciated. STEF
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More