Category: PHP
-
Magento 2 : How to fix tablespace for table exists | base table or view already exists
Fixing General error: 1813 Tablespace for table xx Please DISCARD the tablespace before IMPORT and SQLSTATE[42S01]: Base table or view already exists Recently I encountered this error while upgrading an extension on Magento 2.2.2 The error was When I tried to fix the above error, I received: So here is how to fix it: Important…
-
Remove sku column from Magento 2 invoice and pdf
Edit the file/vendor/magento/module-sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php Inside function draw(), remove/comment following code: To remove the SKU header in table header, edit the file/vendor/magento/module-sales/Model/Order/Pdf/Invoice.php and copy the file vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtmlto app/design/your/theme/Magento_Sales/templates/email/items/order/default.phtmland remove the code
-
Magento 2 temporary fix for Alphabetical sorting of Configurable product options
Just re-write the file vendor/magento/module-configurable-product/Model/ConfigurableAttributeData.php
-
How to add custom attributes in Magento 2 product CSV export
Core Method is to edit the file /vendor/magento/module-catalog-import-export/Model/Export/Product.php and Edit the variable $_exportMainAttrCodes Add your attributes in the array like “custom1″,”custom2”, etc and save the file. Next time you export the csv, you will see new columns in the file.
-
Insert Indian States in Magento Database
Connect to your server’s database using mysql cli or phpmyadmin and use the following query INSERT INTO `directory_country_region` VALUES (NULL,”IN”,”AP”,”Andhra Pradesh”), (NULL,”IN”,”AR”,”Arunachal Pradesh”), (NULL,”IN”,”AS”,”Assam”), (NULL,”IN”,”BR”,”Bihar”), (NULL,”IN”,”CG”,”Chhattisgarh”), (NULL,”IN”,”GA”,”Goa”), (NULL,”IN”,”GJ”,”Gujarat”), (NULL,”IN”,”HR”,”Haryana”), (NULL,”IN”,”HP”,”Himachal Pradesh”), (NULL,”IN”,”JK”,”Jammu and Kashmir”), (NULL,”IN”,”JH”,”Jharkhand”), (NULL,”IN”,”KA”,”Karnataka”), (NULL,”IN”,”KL”,”Kerala”), (NULL,”IN”,”MP”,”Madhya Pradesh”), (NULL,”IN”,”MH”,”Maharashtra”), (NULL,”IN”,”MN”,”Manipur”), (NULL,”IN”,”ML”,”Meghalaya”), (NULL,”IN”,”MZ”,”Mizoram”), (NULL,”IN”,”NL”,”Nagaland”), (NULL,”IN”,”OD”,”Odisha”), (NULL,”IN”,”PB”,”Punjab”), (NULL,”IN”,”RJ”,”Rajasthan”), (NULL,”IN”,”SK”,”Sikkim”), (NULL,”IN”,”TN”,”Tamil Nadu”), (NULL,”IN”,”TL”,”Telangana”), (NULL,”IN”,”TR”,”Tripura”), (NULL,”IN”,”UK”,”Uttarakhand”), (NULL,”IN”,”UP”,”Uttar Pradesh”),…
-
How to create Magento 2 category programmatically?
Use this code:
-
How to secure a folder by whitelisting one IP using HTACCESS and denying all others
The process involves matching all requests for an IP, if the IP does not match redirect all secured directory requests. If you want to control this IP using a script, you can add 2 lines ###CUSTOM RULES### # your rules will appear here using php script ###CUSTOM RULES### Now add a script, say happy.phpand use…
-
Start a magento instance programmatically
This Code:
-
Commonly used regular expressions (regex) for developers in PHP
Commonly used regular expressions (regex) for developers in PHP Regex are used or can be used almost everywhere strings are involved. If you are dealing with text strings, you would often find patterns in them and you might be required to filter few of them based on some similarities and properties. For example: a currency…