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

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.

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();
Create Row and set the created array and then save
$sitestoreproduct = $table->createRow();
$sitestoreproduct->setFromArray($values);
$sitestoreproduct->save();
Finally Commit the Database.

Related

Odoo How to create a new model for Product Master with all the data in the product master

I want to create a separate view for Product Master.I created a new model and tried like this.But when I checked in database no data is present in my new model.
Code
class QuotationCreation(models.Model):
_name='quotation.creation'
xn_product_id = fields.Many2one('product.template')
product=fields.Char(related = 'xn_product_id.name',string='Product')
How can I tranfer all the data from product master to this model.
I want to create a new model with existing data.How can I do that ?
Thanks in Advance
For populating your new model with your existing product.template table records, you have to run a for loop in your odoo shell, because this are existing data that you cannot fire any event on create method. For example:
ProductTemplates = env['product.template'].search([])
for pt in ProductTemplates:
env['quotation.creation'].create({'xn_product_id': pt.id})
env.cr.commit()
OR you can even export all database id from product template list view and import that on quotation.creation list view with no other field which will create all the records in your new table.
For future records, you can just inherit product.template models create() method and create a corresponding quotation.creation record in it.

create new user account manually on prestashop

I am developing a module that get user data in a page , I wand to submit this data to prestashop database to create a new user account .
so how can I do this ?
how should I understand what data I should get from user Like email,phone number and etc . (I want to know this Shop get what data from user to sign them up).
thank you
You can use this piece of code to create a Customer.
$customer = new Customer();
$customer->firstname = 'John';
$customer->lastname = 'Doe';
$customer->email = 'johndoe#gmail.com';
$customer->passwd = md5(pSQL(_COOKIE_KEY_.'yoursecretpasswordhere'));
$customer->save();
Like Madhi said, you will get all information needed for the Customer in Customer.php
Cheers :)
All the things you need are defined in the "classes/Customer.php" file.
Each PrestShop class has one "public static $definition" and each field of the $definition that has the "'required' => true", is required

Get value from customer_entity_varchar - Magento

I created a customer attribute in backend magento, but I want to show this attribute to the user so that he can alter its value in the frontend. My input field is being displayed in the frontend, but the value is not there. I am not able to get this value. I found that the value that I need to display is in the apscustomer_entity_varchar table and the column is called 'value'. How can I get that value from that table? I was trying this:
$collection = Mage::getModel('eav/entity_attribute')->getCollection();
foreach ($collection as $data) {
return $data;
}
but it was not working, so I used SQL code and it worked. However I know that's not a nice way to do that in Magento. What I did was something like:
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = "SELECT * FROM `apscustomer_entity_varchar ` WHERE `entity_id`='$id'";
$rows = $connection->fetchAll($sql);
How can I get the value column from my apscustomer_entity_varchar table in the magento way, using the getModel?
You need to retrieve the customer of the session and then you can get the attribute you want :
Mage::getSingleton('customer/session')->getData('attributeName');
Mage::getSingleton('customer/session')->getAttributeName(); //Magic getter
Where attributeName is the name of the attribute you want to get the value.
I found out how to do that :D
It's actually very simple. Even if this is a custom customer attribute (created in Magento admin panel), I need to get the attribute not using the 'eav/entity_attribute' model, but using the 'customer/customer' model. So I just need to do that:
$customer_data = Mage::getModel('customer/customer')->load($customer_id)->getData();
echo $customer_data['attributeThatYouWant'];
If you are not sure what is the name of your attribute you can look at Magento Admin Panel under Customer/Manage-Attributes, or you can use that after getting the model:
var_dump($customer_data);
Now you are able to get the name of all customer attributes.

how to update prestashop product details from external database?

i have one grocery shop and i have thinking to sell this product online .so i used one CMS cart called "prestashop" .
even i have installed and start working on that .but i have some problem.
i have my own inventory database to store all product details . with a UI that i can add product details to database (quantity, price etc) . now my question is how can interact with my inventory database using prestashop cart ?
is it possible ? what is the best way to do it ? please help
You can add the categories from external db using a script in your prestashop site. For this create a module with frontcontroller (for cron job or to run the script) and inside the script select the categories from external db, then loop through the categories and inside the loop create prestashop category object and place the category fields to the category object and call the category save method.
public function initContent()
{
parent::initContent();
$temp_categs = array(); //
//fetch data into $temp_catgs from the external db with the help mysqli_connect or whatever the driver - never modify presta db settings - write php code for db connection to external db and fetch
//loop through the fetched categories
foreach($temp_categs as $categ){
$new_categ = new Category();
//set all the field values
$new_categ->name = $categ['name'];
$new_categ->id_parent = $categ['id_parent'];
$new_categ->active = true;
$new_categ->field2 = $categ['field2'];
$new_categ->field3 = $categ['field3'];
//save the category - a category with new id will be created in prestashop
$new_categ->save();
}
}
}
I hope this would help you.

Yii-CRUD: Getting select boxes filled with data from other tables

Do I need some more work, to get a select box with the corresponding data (e.g. land list from an another db-table) in the created insert form (via CRUD) or it is enough to define the relations in the models and yii would do this for me automatically?
Since you haven't provided any code, let me show you with an example. Suppose we have a user table and a group table and need to select a group for a user which is selected with a select box.
In the user model you can have a function like
public function getGroupName()
{
return CHtml::listData(Group::model()->findAll();
}
In the form view of user create you can populate the select box like below:
<?php echo $form->dropDownListRow($User, 'group_id', $User->getGroupName(),array('prompt' => 'Select ...')); ?>