Show All Indexes On a DB
Again, not Magento. Very handy though!
SELECT DISTINCT
TABLE_NAME,
INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'your_schema';
Then you can use show indexes from table_name
to see more info about the index.
Related cards:
Fetching All Attributes For An Entity From The DB In One Query
Using the database to inspect EAV-based entity types can be a real pain in the ass, so here are a bunch of queries that let you inspect some popular EAV entity types easily. This practice can be applied to any EAV entity type, however as there are...
Product Attribute Addition
This code shows all possible configuration options for an attribute that I know of, you need not include all of these when adding an attribute (although it won't hurt)
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
...
Stock Availability on Credit Note, Cancellation and Payment Deny
In summary - making a credit memo can increase the stock quantity but will never set the "Stock Availability" of the product to "In Stock", whereas a config option can control whether an order cancellation sets "In Stock" automatically. Denying a ...
Many to Many Resource Model Mapping
This is some boilerplate code to facilitate the use of many-to-many relationship tables in Magento. I found myself rewriting this code often, so this saves some time. This example links a sizeguide entity to attribute sets. Obviously you'll need t...
Product EAV Attribute Set, Group and Attribute List
To see a list of all attribute sets, groups, and associated attributes for products, use this SQL. BONUS! Also shows the sort ordering, useful for determining which sort_order
you need to place an attribute in a certain position:
SELECT...
Associating An Orphan Sage Pay Suite Transaction With An Order
We had a situation whereby a client placed an order and went through Sage Pay
succesfully, however the order was not able to be created on Magento, so we had
an error stating "WARNING - There are approved Sage Pay transactions that have
no associa...
Allowing Import Of Invisible Attributes
By setting a Product Attribute to be invisible via the visible
property, you stop the ability to import that attribute unless you alter the _forcedAttributesCodes
property of...
Pretty Backtrace / Stack Trace
In app/code/core/Mage/Core/functions.php
Magento offers a function named mageDebugBacktrace()
which is nice, but I thought could be made nicer. This backtrace shows frame numbers, file names and line numbers, classes, methods and arguments whe...
Add All Attributes To A Collection
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$collection->addAttributeToSelect($attributes);
Creating an EAV Entity
Overview
A overview for those familiar with making flat models:
- Your config is standard, your table name takes the form of the base (entity) table
- You name your resource models as normal (so by class name, you can't tell the difference b...