[Magento 2] Migration errors: Data Integrity Step

Noting down the errors and possible solutions I get while migrating data from Magento 1 to Magento 2. In the data integrity step we can find many type of errors. Here you have some of them, explanation and solution: Error Foreign key (FK_CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID) constraint fails on source database. Orphan records id: 121,182 from catalog_eav_attribute.attribute_id has no referenced records in `eav_attribute Explanation A catalog eav attribute (product attribute or category attribute) was created in the past Read more…

[Magento 2] Add require fields dynamically in a form

Recently I had to modify the customer registration form from one of the websites I manage. VAT ID had to be included but only for professional customers. This meant that when a customer clicked on the Ā«I’m a professionalĀ» field, new fields should show up and, the most important, the TAXVAT field had to become required (when in Magento is not required). This solution is not perfect because it uses just the javascript validation. But Read more…

[Apache] How to correctly protect your Magento backoffice with htpasswd

One of the good security practices in Magento (either 1 or 2) is to protect your backoffice url with password using htpasswd (directly in the Apache conf or in the htaccess file). It is not the perfect solution, but it adds an extra layer of security which: Will prevent anyone trying to log from anywhere Will prevent brute force attacks. This particular case is what we’ve experienced in our Magento stores. Apache configuration This is Read more…

[Magento 2] How to clean the cache by TAG

Cleaning the cache by TAG is quite easy in Magento 2. You will need to: Inject the classes in your construct function Know the exact tags you want to cache Flush the actual Cache Start creating your class injecting the classes we need: Create a function to retrieve the tags you want to flush. For example, for a CMS page with an ID 2: And, in a custom function you can just execute the cache Read more…

[Magento 2] Adding custom category attribute (with scopes)

Creating a new category attribute should be easy in Magento 2. It is, more or less. Follow these steps and you will get to it: Files you will need to create A quick screenshot of how your module will look once you create it: YourCompany/YourModule/registration.php YourCompany/YourModule/etc/module.xml YourCompany/YourModule/Setup/InstallData.php YourCompany/YourModule/view/adminhtml/ui_component/category_form.xml This code should be enough to create the category attribute. However, even though we have created the attribute passing the parameter ‘global’ = \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, you’ll see that Read more…

Default Magento 2 modules you should disable

Magento 2 includes many default modules that you probably won’t ever use. This is my proposed list and you can disable it directly using the following command: Magento_*Analytics Requires a subscription Magento_Marketplace If you’re a developer installing modules via composer, this is not necessary Magento_AuthorizeMagento_Braintree Not necessary if you don’t use Authorize.net/Braintree payment service provider Magento_Weee Related to particular product taxes. Read the doc to see if you need it… but I don’t think so Read more…

Redsys Test Cards

If you use Redsys (payment platform used by Spanish banking like CaixaBank, Banco Santander, Banco Sabadell and many others), you may want to have different test cards for your test platform. I want to share with you the ones provided by the official documentation: Type PAN 3DSecure v.2 3DSMethod Authorization Type Authorization 4548812049400004 No No CIP Authorization 5101332200023012 No No – Authorization 374245455400001 No No – Authorization 4918019160034602 Yes Yes Frictionless Authorization 4548814479727229 Yes No Read more…

Apache redirections when switching Magento from Single Store to Multistore

Recently we converted a 10 years old Magento single store to a Magento Multi Store. We wanted to add English language (original language was Spanish). We did this by creating a new store, asigning the code /es/ to the Spanish store and /en/ to the English store. To avoid SEO issues, we had to create some redirection rules: Everything that was on the root path / had to be moved to /es, except for some Read more…