Próbowałem zrobić to poprzez:
Kod: Zaznacz cały
$mediaApi = Mage::getModel("catalog/product_attribute_media_api");
$items = $mediaApi->items($product->getId());
foreach($items as $item)
$mediaApi->remove($product->getId(), $item[’file’]);
i otrzymuje błąd
Fatal error: Uncaught exception ‘Mage_Eav_Model_Entity_Attribute_Exception’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`base_xxx`.`catalog_product_entity_media_gallery_value`, CONSTRAINT `FK_CAT_PRD_ENTT_MDA_GLR_VAL_VAL_ID_CAT_PRD_ENTT_MDA_GLR_VAL_ID` FOREIGN KEY (`value_id`) REFERENCES `catalog_prod)’ in /home/users/xxx/public_html/app/code/core/Mage/Core/Model/Config.php:1348 Stack trace: #0 /home/users/xxx/public_html/app/Mage.php(462): Mage_Core_Model_Config->getModelInstance(’eav/entity_attr...’, ‘SQLSTATE[23000]...’) #1 /home/users/xxx/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php(661): Mage::getModel(’eav/entity_attr...’, ‘SQLSTATE[23000]...’) #2 /home/users/xxx/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php(1648): Mage_Eav_Model_Entity_Abstract->walkAttributes(’backend/afterSa...’, Array) #3 /home/users/xxx/public_html/app/code/core/Mage/Catalog/M in /home/users/xxx/public_html/app/code/core/Mage/Core/Model/Config.php on line 1348
Próbowałem też poprze polecenia SQL kasować odpowiednie wiersze w catalog_product_entity_media_gallery i catalog_product_entity_media_gallery_value
ale mam to samo