Saving Extension Config Data Magento - magento

I've been trying to figure out exactly how does magento save the config data for a module given in System.xml. reason?I would like to edit the data provided by the user before storing it in the database.
Any clues????

Take a look at Mage_Core_Model_Store::setConfig function (and getConfig for reading the value). You will probbably have to write an observer that will listen to store_save_before event.
Magento stores configuration data in core_config_data database table - path column is the hierarhical structure of XML elements in system.xml file and is the same as XPath used for reading the default value out of config.xml file and value column contains the value that was saved.
When accessing the data with for e.g. Mage::getStoreConfig( 'path', $storeId ); Magento first searches the table for path-value pair and if it doesn't find it it reads the default value from config.xml file.

Related

upload and dowanload Files in ORACLE APEX

i have costumer's every one i have to upload mullite files
so is there any way to get it?
i create table with
FILE_NAME
FILE_MINETYPE
FILE_CHARSET
i see many video's but they aren't useful for me
You need to create a Page Item with the type File Browse.... Then, under Storage Type, you can use your own custom table or you can use APEX_APPLICATION_TEMP_FILES.
If you use APEX_APPLICATION_TEMP_FILES it will automatically save information about the file type such as file name, mime type, etc. If you use a custom table, you will need to designate which column in the table should hold which file attribute.
You will also need a button or some way of submitting the page. Once the page is submitted, the files will be uploaded and saved to the database.

Change to magento indexer process

I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically. I've found that the urls of every product are in the enterprise_url_rewrite table, request path field.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Good afternoon! Let's break this down:
I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically
Yes - you can create URL rewrites dynamically using the Magento models that represent the database table you've identified already:
/** #var Enterprise_UrlRewrite_Model_Redirect $rewrite */
$rewrite = Mage::getSingleton('enterprise_urlrewrite/redirect');
// Create new record or load the existing one
$rewrite->loadByRequestPath($requestUrl, $store->getId());
$rewrite
->setStoreId($store->getId()) // define which store the rewrite should be
->setOptions(null) // specify any rewrite/redirect/custom options
->setRequestPath($requestUrl) // specify the request URL
->setIdentifier($requestUrl)
->setTargetPath($targetPath) // specify the redirect target
->setEntityType(Mage_Core_Model_Url_Rewrite::TYPE_CUSTOM)
->setDescription('Add a comment if you want to');
$rewrite->save();
This will attempt to load an existing URL rewrite/redirect by the $requestUrl and will return an empty model if it was not found which you can embellish with your data and save.
The "options" define whether it's a temporary or permanent redirect (302 vs 301).
More information here via the Magento EE user guide.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Don't worry about it. The (modern) Magento database has table triggers wherever records need to be indexed, and will detect creations, updated and deletions on those tables. The indexers will detect that change need to be made and will make them for you as required.
If you're seeing URL rewrites disappearing it's most likely because you've been adding them directly to the index table with SQL, so the table is rewritten whenever the indexer runs. To avoid this use the model as noted above and everything will be saved into the correct location and indexed properly.

How to add image field in dynamic input group for magento admin configuration setting?

I have created a module which add dynamic input group to magento admin configuration.
I have added image field but it can't save in database. Means if I select image than only image store in database in core_config_data — the encrypted value of row (just image field value)
If I remove image field than the data saved properly in database along with other inputs.
So here I can't save image type data with other data of dynamic input.
I've found reason + solution, maybe this is helpful for someone. Magento is using the wrong backend model. For saving images the backend model must be system_config_backend_image. But as you've added the fields dynamically (and not inside the system.xml) the fields have no assigned backend model, so magento will use the default for text values etc..
The solution is, to use the clone_fields functionality. Please find my explanation how to use it on my blog post http://www.mellority-report.com/magento-dynamic-config-fields-with-custom-backend-models/

How to create multi store module in the Magento

I want to create my custom module multi store compatible. I want to get the value from my custom database table as per configuration scope. While adding the values to the database table, i have specified the scope_id and scope like as Magento does in the core_config_data table. Now how can i fetch those inserted value from the table according to the selected website on the front end.
I have the following database value snippet.
ID value scope_id scope
1 test 0 default
2 test1 4 store
3 test12 5 website
Can anybody help me in this? Thanks
It is not so easy to reuse Magento's config loading for your own needs.
What you want is to inherit your values from default -> website -> store (if not overwritten in there).
Magento converts the database config to the internal XML representation in Mage_Core_Model_Resource_Config::loadToXml and does the merging and inheritance logic in there.
The inheritance logic is all in the loadToXml() function - so you could implement something similar if you want to take the same approach and build your values for each store scope.
If you simply need to get one value for a specific scope you just have to read the database row with that store, if not found with the website the store is in, if not found the default value.

Magento - Store Config only added to database after being saved

I have noticed that in Magento the core_config_data table is very small just after installation and it gradually gets populated over time ONLY when sections of the system config are saved. For example there are no values in the core_config_data table for the contacts settings - yet i can still do Mage::getStoreConfig('contacts/contacts/enabled') and get the correct value.
So, does this mean that magento is simply reading the config xml until a value is saved, and at which point it saves to the database and then the value is read from there?
If this is the case, then surely this is a bad design pattern, having these values stored in two places?
I think this post may help.
The Magento Config: Loading System Variables

Resources