When developers set up test environments of production websites, often the database dump used for the development site contains real customer and order data. Usually this data should be removed from development environments for security reasons. You might also fail tests from compliance scanning software. To create a Magento database dump without sensitive data is …
In Magento Commerce Edition version 1.13 and above and in Magento 2, there exists definer clauses in Magento database exports when you export the database from the server it resides on.
These definer clauses are used in MySQL triggers and contain the username and host of the server the exist on. They do not pose …
Error
You may encounter a Cannot retrieve entity config: modulename/tablename error in Magento when adding a setup script.
Solution
There are two main causes of this error. The first is to ensure that when you define your lt;resourceModel> within your module’s config.xml file, for example:
<models>
<modulename>
…
Often when copying data from a production website to a development environment, common requests from clients is to obfuscate customer data to remove any resemblance of real customer information. So how do we go about anonymising data on a Magento development site?
It’s important to note the areas of data that will need to be …
What makes something either a simple Model or an EAV Model in Magento is its Model Resource.
Whenever you’ve defined a custom model, resource model and collection, more than likely your resource model will extend the Mage_Core_Model_Resource_Db_Abstract class.
An EAV resource model extends the Mage_Eav_Model_Entity_Abstract class, rather than Mage_Core_Model_Resource_Db_Abstract.
Their collections also extend the Mage_Eav_Model_Entity_Collection …
Within the admin area, Magento gives us the ability to enable Flat Catalog Product and Flat Catalog Category options.
Why would you want to enable these? Well, usually, these tables store information about category and product data in many different tables, and so querying for this information, such as when on a category page …
Since Magento 1.6 was released, Magento supports more database backends than just MySQL. So in order to make our module setup scripts cross-database compatible, Magento offers a DDL (Data Definition Language) Table object. The Magento Varien_Db_Ddl_Table class can be used to add, create or remove columns within setup scripts of modules. Coupled with the Mage_Core_Model_Resource_Setup …
We can load Magento collections a couple of ways. As an example, if we take a look at the loading the catalog product collection, the following two lines would bring back the collection.
Collection classes inherit from Mage_Core_Model_Resource_Db_Collection_Abstract that in turn inherits from Varien_Data_Collection_Db that inherits from Varien_Data_Collection
The Varien_Data_Collection_Db class contains some useful methods.
Magento data scripts that are located within the modules’ data directory were introduced in Magento Community/Open Source version 1.6.
The naming convention for the data script files have a similar naming convention to setup scripts that are found within the modules’ sql directory.
The data file names themselves are proceeded with a data- prefix.
This article will demonstrate how to go about adding Magento install and upgrade scripts. Assuming you have read how to add models, resource models and collection, you should be in a good position to add the setup scripts.
Let’s continue with our example store information previously and add data to that.
First of …