Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:38:25+00:00 2026-05-23T07:38:25+00:00

I guys i try to create a custom product from a module with this

  • 0

I guys i try to create a custom product from a module with this code :

$defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));  
/* Add a new product */
$object = new Product();
$object->price = 22;
$object->id_tax_rules_group = 0;
$object->name = 'test';
$object->id_manufacturer = 0;
$object->id_supplier = 0;
$object->quantity = 1;
$object->minimal_quantity = 1;
$object->additional_shipping_cost = 0; 
$object->wholesale_price = 0;
$object->ecotax = 0;
$object->width = 0;
$object->height = 0;
$object->depth = 0;
$object->weight = 0;
$object->out_of_stock = 0;
$object->active = 0;
$object->id_category_default = 18;
$object->category = 18;
$object->available_for_order = 0;
$object->show_price = 1;
$object->on_sale = 0;
$object->online_only = 1;
$object->meta_keywords = 'test';
if($object->save())
    $object->add();
echo "produit ajouté";

The code works fine, the product was added to the database but wasn’t display in the back office, someone have an idea to solve this problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:38:26+00:00Added an answer on May 23, 2026 at 7:38 am

    The name and meta keyword field are both multi-language arrays. If you look at AdminImport.php in admin/tabs you’ll find the definition for a function:

    private static function createMultiLangField($field) 
    

    Copy this function into your module and you can use it to create a suitable array for these multi-language fields if you call it by passing your text as the $field parameter (it will set the value for all languages to the string you pass in). You should also set a default value for the description_short and link_rewrite fields:

    $object->description_short = array((int)(Configuration::get('PS_LANG_DEFAULT')) => '');
    

    and

    $object->link_rewrite = array((int)(Configuration::get('PS_LANG_DEFAULT')) => '');
    

    The second point is that although you’ve set the default category, you will also have to explicitly set id_category as an array e.g.

    $object->category=array(18);
    

    I also think you should then set the categories explicitly with:

    $object->updateCategories($object->category, true);
    

    It should then appear in the catalog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guys I wrote this code and i have two errors. Invalid rank specifier:
I'm try to create a sliding banner with jquery here. I tried to code
Hi guys I get this coercion error: TypeError: Error #1034: Type Coercion failed: cannot
I have this code in java : try{ //some code here.. . } catch
Do you guys see any issues with this C# code? It gets email notifications
Guys, I’ve been writing code for 15+ years, but managed to avoid Web Development
Hi Guys could you please help me refactor this so that it is sensibly
Ok guys and gals, here is my problem: I've built a custom control that
Hi Guys can you please help me with this error? What is it? Server
I'm writing up custom code for a CMS for a website. When a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.