Search code examples
socialengine

How can I create a "Product" of a Store programatically in SocialEngine (I am having StorePlugin)


I have Socialengine with Store Plugin.... I want to create a product in store programatically(Not using GUI and Not using Admin Panel) from an other module like events.


Solution

  • Steps 1. Get the owner_id from viewer 2. Query for store_id from "sitestore_stores" table 3. Create an array having all the fields like in table "sitestoreproduct_product" 4. get the Adapter

    $table = Engine_Api::_()->getItemTable('sitestoreproduct_product');
    $db = $table->getAdapter();
    $db->beginTransaction();
    
    1. Create Row and set the created array and then save

      $sitestoreproduct = $table->createRow();
      $sitestoreproduct->setFromArray($values); $sitestoreproduct->save();

    2. Finally Commit the Database.