Prestashop 1.6 custom module how to add custom input and table in Configuration at Back Office - prestashop

I am trying to create a custom footer module for my site, It is my first time to create a module in prestashop 1.6 and I read about this article
http://doc.prestashop.com/display/PS16/Adding+a+configuration+page
my problem is i cannot fully understand if I need to create a custom table for my module or not
Configuration::updateValue('FOOTERCUSTOM_NAME', $footercustom);
as you can see in this code, the Configuration table is already created and Configuration::updateValue is a default prestashop code
if I wanted to create a input 1 , input 2 and input 3 at our configuration page in module backoffice and it automatically output the data in the database at my hookfooter.
what is the proper way of doing this?
Note that I already succeeded in creating a basic module, my main problem in how to insert data on my database using the configuration in my module

You don't have to a create a custom table. With the Configuration::updateValue method you can store/update values in the ps_configuration table and you can retrieve these values with the Configuration::get and Configuration::getMultiple methods. Values can be removed with the Configuration::deleteByName method.
Example:
Configuration::updateValue('FOOTERCUSTOM_INPUT_1', $input1Stored);
$input1Retrieved = Configuration::get('FOOTERCUSTOM_INPUT_1');

You can refer to this guide as well, still valid
http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-ThegetContent()method

Related

Create a folder about an item with Microsoft Graph Sharepoint

How do I create a folder on my list? I can create a file but I can't define a type.
Should I define a type column? But how can I create a column with a type characteristic?
I am using Graph Explorer to build and want to use PHP after for my Laravel website.
Thank you for your answers !
After testing and testing, i find my request.
If it can help someone :
POST https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}/children
site-id is composed about two ID, site-id and subsite-id.
To find your site-id :
GET https://graph.microsoft.com/v1.0/sites/root
My subsite-id is my groupsite id, you can find him on :
GET https://graph.microsoft.com/v1.0/sites/{sites-id}/lists?search=doc
After i did a request to find {item-id} :
GET https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test
And to end :
POST https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}/children
You can create a new list with a document library as a template. Then you will have a new drive in the root of your site where you can create a folder.

Wrong "ReflectedWorkItemIDFieldName" while migrating Azure DevOps Work Items

I am testing the azure-devops-migration-tools and have create a project using https://azuredevopsdemogenerator.azurewebsites.net/ (Parts Unlimited). I have generated the configuration.json and changed the Source and Target so I can test a migration, but I'm getting errors while migrating Work Items.
[15:14:41 ERR] Error running query
Microsoft.TeamFoundation.WorkItemTracking.Client.ValidationException: TF51005: The query references a field that does not exist. The error is caused by «ReflectedWorkItemId».
I've tried different options on the "ReflectedWorkItemIDFieldName" field, Scrum, Basic, Agile, Custom, empty but am still unable to migrate the work items.
How can I get the value to put on this field for the specific project?
Thanks,
Bruno
Quick Solution: Most ADO instances use the prefix 'custom' for new fields. Try "Custom.ReflectedWorkItemId" in your configuration.json to see if that resolves the problem.
More details: It's hard to tell without an actual configuration.JSON file to review. One possible problem is that you need to use the actual and full internal 'Name' of the ReflectedWorkItemID field. This doesn't show in ADO, or the Process Template when created. The recommendation is that you create a query referencing your custom field, and export the WIQL file (query file). Once you export the WIQL file, you can then open the file and see the full syntax of the custom field.
Exporting Queries: If you don't know how to do this, it can be done with VisualStudio. If you don't know how to do that, you can install this extension. It's a handy WIQL import/Export and editor. Install, and your ADO Queries with have an Edit in WIQL Editor option. Create a query that exposes your 'ReflectedWorkItemID' as a column, then edit that query in the WIQL editor and see the full names of the Reflected Work Items ID Feild. https://marketplace.visualstudio.com/items?itemName=ottostreifel.wiql-editor
SELECT
[System.Id],
[System.WorkItemType],
[System.Title],
[System.AssignedTo],
[System.ChangedBy],
[Custom.ReflectedWorkItemId]
FROM workitems
WHERE ...
I found a possible solution. I have created a custom process, change the process from the projects to this new one and add a new field. This is the field I'm using on the configuration.json and now I'm able to migrate work items
To make the migration in the "ReflectedWorkItemIDFieldName" you must do:
"Organization Settings" -> Process -> Select the process where you project are (Basic, Scrum, Agil, or CMMI).
then click on the 3 dots and create a new Inherited process.
Then with the inherited process, you are able to create a new field for each work item type. The name that you type (could be "IronMan") that name will be in your configuration file.

Adding new field on Odoo Product Variant

I am trying to add new field to product.product model.
What I've done so far is:
Add new field on the following model (From Settings > Database Structure > Models):
product.product
with the following details:
Name: x_product_cost
Field Label: Product Cost
Field Type: Float
and leave the rest to default.
The problem is i am unable to show it on the form. This is the only code that is generated when I tried to edit Form:
View Name: product.product.form
Object: product.product
Inherited View: product.template.common.form
Product Variant
lst_price
I can't use product.template model, since that inherits to product.product
Am i missing something here?
PS: I am trying to temporarily fixed assign-different-cost-on-product-variant bug as specified here
https://github.com/odoo/odoo/issues/1198
Can anyone help me with this?
Actually instead of modifying the model from the Odoo configuration, you should create a custom module, in which you will add the new fields and the new behaviors that you need.
To do so you will have to inherit from the models in the python files to extend them, and you will surely have to modify the views as well, so that your custom fields get displayed.
For reference on how to extend models, create a custom module and create the views, you should refer to the Odoo documentation that you can find here.
As an additional note in case you didn't know, but their is a new API that appeared in the version 8 of Odoo, if you can use it, it is much easier and much nicer.

How to access Customizable Text Fields From Prestashop Module?

I'm creating a new module for Prestashop where users can design their own product from a third party service. When the user later adds the product to their cart, I would like to save a ID that I get from this Third Party Service where the user designed their product.
I guess the best way to do this is to create a Customization Textfield within Prestashop called "designID". Now I want to know how I save data to this field from module development in Prestashop instead of letting the users manually fill in the data.
So basically... How do I add data to these customizable fields from within a Prestashop module, when the user adds the product to their cart?
These customization fields are used if you are simple user and you are not designing a module. Using it to save the designID will be just a hack.
Since you're creating a new module my advice is to keep the 3rd party ID in a newly created database table, which will match the id_product, id_design, id_cart, id_order, etc...
You can hook to "actionCartSave" and add the record with the matching ids, and all the other required data at your table.
If you want to stick to that Customization feature, add a sample field and review the following database tables:
ps_customization
ps_customization_field
ps_customization_field_lang
ps_customized_data
and replicate the changes when you receive the 3rd party ID.
If all your products will be customized, consider adding the required data in ps_customization_field & ps_customization_field_lang (the table for the field structure) during the module installation, so after it's installed you can just fill
ps_customization & ps_customized_data (the tables for the field data)
PrestaShop does not have proper API for adding customizations, only for retrieving data, so you'll have to write the SQL queries yourself. Just review the ProductController for the ps_customization & ps_customized_data changes and the AdminProductsController for ps_customization_field & ps_customization_field_lang.
Do not forget to remove the Customization markup code from your product & cart templates.
I was able to find this out by myself by first trying to use Customization for a couple of hours without any success.
So basically how my module work is that the customer can open a popup iframe to a third party design tool, the customer then save the design in the iframe, which then sends the data to the parent window (The Prestashop Window).
So to store this I did the following:
Add a new column to the database table ps_cart_product
Hook into any display-hook on the product page and check if any post data is send containing the data from the third party module. If so, then:
if(isset($_POST['thirdparty'])){
$id_product = (int)Tools::getValue('id_product');
if (!$this->context->cart->id){
$this->context->cart->add();
if ($this->context->cart->id)
$this->context->cookie->id_cart = (int)$this->context->cart->id;
}
$this->context->cart->updateQty(1, $id_product);
if(!Db::getInstance()->update('cart_product', array('id_design'=> pSQL(trim($_POST['thirdparty']))) ,'id_cart = '.$this->context->cart->id.' AND id_product = '.(int)Tools::getValue('id_product') ))
$this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
}
So basically first I check if POST is set, then I check if any cart exist, if cart does not exist then add a new cart with ->add() (This function took hours to find, 0 documentation). updateQty() is used to update the cart with the new product.
The last part is the SQL query that updates the value of id_design column with the data that is send from the third party.

How to update the values of Magento products using installer/update scripts and Magento abstractions?

I added a custom eav attribute to my Magento application product entity using an installer script (Basically, following the procedure described here: Installing Custom Attributes with Your Module). Now, I want to use an update script to change (populate) the values of this attribute for each product according to some criteria (based on the product category). The script I attempted to use was essentially like this:
$attributeValues = array(...) // Map from $productId to the desired $value
$product = Mage::getModel('catalog/product');
foreach($attributeValues as $productId=>$value){
$product->load($productId)->setMyAttribute($value);
$product->save();
}
My questions would then be: Is it ok to use this level of abstraction (Mage::getModel('catalog/product') and its methods) in update scripts? If it isn't, how would you recommend to change these attribute values using update scripts (without requiring sql)?
The script I used (until now) has not worked and failed with the error:
Call to a member function getStoreIds() on a non-object
in a magento core file.
I don't know if this error is a Magento bug or is a problem with how I'm using the update scripts.
I'm using Magento 1.4.0.1
Data update scripts are the way to go
Simply use a data upgrade script for this. This is a script placed in the data folder instead of the sql folder. Those scripts run later then the database structure updates, and allow access to more functionality.
Example file names:
app/code/local/My/Module/data/your_setup/data-install-0.1.0.php
app/code/local/My/Module/data/your_setup/data-upgrade-0.1.0-0.2.0.php
This is already available in Magento 1.4.
Try adding Mage::app()->setUpdateMode(false) in your sql upgrade script. e.g.
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');;
$installer->startSetup();
Mage::app()->setUpdateMode(false);
Mage::app()->setCurrentStore('your_store_code_here');
If you look in Mage::app()->getStore() you will see the following snippet that returns an incorrect store which is required for saving a product.
if (!Mage::isInstalled() || $this->getUpdateMode()) {
return $this->_getDefaultStore();
}