To delete all product related data, use the following query: DELETE FROM catalog_product_entity; Due to the constraints it will delete all related data from other tables as well.
Deleting all products using SQL (Magento 1)
Want to remove all products from your Magento store directly through the database? The following statement removes the products and their related data:
|
1 |
DELETE FROM catalog_product_entity; |
Thanks to the constraints on this table, product relationships are also removed from the relevant tables.
Getting products with or without custom options using SQL (Magento 1)
To get all products that do not have custom options, simply run the following SQL query: SELECT * FROM catalog_product_entity WHERE entity_id NOT IN (SELECT DISTINCT product_id FROM catalog_product_option); To get all products that do have custom options, remove the…
Finding products with and without custom options using SQL (Magento 1)
To find all products that have keine no custom options, run this query:
|
1 2 3 4 5 6 |
SELECT * FROM catalog_product_entity WHERE entity_id NOT IN (SELECT DISTINCT product_id FROM catalog_product_option); |
To find all products that do have custom options, simply remove “NOT” from the query above.
Importing gallery images using MAGMI (Magento Mass Importer)
To import Magento gallery images using MAGMI (Magento Mass Importer) the following steps are required: Add a new column to your import file. It must be called media_gallery. Now add all your gallery images to that column. The format is:…
Importing gallery images with MAGMI (Magento Mass Importer)
To import gallery images into Magento using MAGMI (Magento Mass Importer), follow these steps: Add a media_gallery column to your import file Then put the gallery images into that column using this format: image1.jpg::label1;/image2.jpg::label2…
Adding a product image description programmatically (Magento 1)
There is no way to add a product image description using the addImageToMediaGallery function. The following code does the job though: foreach($product->getData(‘media_gallery’) as $each){ foreach($each as $image){ $attributes = $product->getTypeInstance(true)->getSetAttributes($product); $attributes['media_gallery']->getBackend()->updateImage($product, $image['file'], array(‘label’ => ‘whatever’)); } }
Adding a product image label programmatically (Magento 1)
If you want to add a label to a product image programmatically, you cannot do this with the addImageToMediaGallery method. The following code, however, does the job:
|
1 2 3 4 5 6 |
foreach($product->getData('media_gallery') as $each){ foreach($each as $image){ $attributes = $product->getTypeInstance(true)->getSetAttributes($product); $attributes['media_gallery']->getBackend()->updateImage($product, $image['file'], array('label' => 'whatever')); } } |
Getting the attribute set name of a product (Magento 1)
Use the following code to get a products attribute set name.
|
1 2 3 |
$attributeSetModel = Mage::getModel("eav/entity_attribute_set"); $attributeSetModel->load($product->getAttributeSetId()); $attributeSetName = $attributeSetModel->getAttributeSetName(); |
Getting the product for cart item (Magento 1)
Use the following code to get the matching product of a Magento cart item:
|
1 |
$product = $item->getProduct(); |