Hot answers tagged

15

You can truncate table using DB Adapter and table name. /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ $connection = $model->getResource()->getConnection(); $tableName = $model->getResource()->getMainTable(); $connection->truncateTable($tableName); Alternatively you can get DB Adapter and table name from collection, ...


12

If you do not see the delete attribute button then that means the table column 'is_user_defined' in the eav_attribute table is set to 0. By changing this to 1 it will show the delete button. If you do not know where to go to find the attribute then you can follow the answers. In the admin Stores->Attributes->Products


11

You can safely delete the files in the following folders: /media/import /var/report Besides of that you can also remove old session files by using find /path/to/magento/var/session -name 'sess_*' -type f -mtime +7 -exec rm {} \; Removing old session files can already have a performance impact. For improving the performance of you Magento installation ...


10

I had a the described issue two weeks ago. The image was not removed from the products Images tab, because the setting from the default scope was overwritten on store view level. So I would suggest checking the products image configuration on the lower configuration scopes (website, store view) to see if the Use Default checkbox was deactivated somewhere. ...


8

Yes after you have imported all the images and it works fine, you can delete all that images in that folder to free up disk space


8

Add a column to your import with this as the header name: magmi:delete 1 is to delete the product 0 is to not delete the product You want to use the Product Deleter v0.0.2 plugin.


8

Yes it is possible, but not as efficient as removing it by ID. The removeItemByKey method uses an unset on the array, so has constant time. To remove a custom item by your attribute, you will need to do a loop: foreach ($collection as $product) { if ($product->getProductCreatorId() == 'YOUR_VALUE') { $collection->removeItemByKey($product->...


8

While it's ok to remove /www/media/catalog/product/cache it's where Magento stores resized images and doing it on a live site will cause a slowdown while Magento recreates all those cached images so it doesn't have to recreate them 'on the fly' whenever it needs to serve them out. It's better to expire out cached images older than X days as removing product ...


7

If you try to delete product from fronend then you need to assign area for that. Add following code to your class. public function __construct( ........ \Magento\Catalog\Model\ProductRepository $productRepository, \Magento\Framework\Registry $registry ) { ...... $this->productRepository = $productRepository; $this->registry = $...


6

First you need to enable the Product Deleter Plugin. Then you need to create a CSV, with columns "sku" and "magmi:delete". For example: "sku","magmi:delete" "00001","1" "00004","1" Then run your import.


6

There is no solution. The problem is, uninstalling a module means to delete it, but when it is deleted, there is nothing more that could uninstall stuff. Some extension provider, provide a SQL-Query which clears the database. One group on one of our hackathons once wrote a module which makes magento core function of using uninstall scripts useable: https://...


6

Here's the personal list I made up over the years: app/code/<codePool> folder app/etc/modules file app/locale translation and email files app/design layout and template files js libraries lib libraries skin js, css and images files shell scripts extra non native folders Regarding database: Tables created by the module core_config_data entries ...


5

When you try to delete a product and observer call Mage_Sales_Model_Resource_Quote::substractProductFromQuotes This method subtract 1 to the items_count of the quotes containing you product ... in case this is already 0 you got the out of range... exception. ( still not sure why in some occasion you already have it to 0 ... ) Solution: I'm still not ...


5

You could create an uninstall shell script that lives in the shell/ folder. That file can remove files, directories, database tables, core_resource entries, and attributes from EAV. It would look something like this: <?php include_once 'abstract.php'; class Namespace_Module_Uninstall extends Mage_Shell_Abstract { public function run() { ...


5

Try the below code: <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $eavAttribute = $objectManager->create('Magento\Eav\Model\Config'); $attribute = $eavAttribute->getAttribute('catalog_product', 'color'); $options = $attribute->getSource()->getAllOptions(); foreach ($options as $option) { if($option['label']...


4

If you set the product to "catalog only", but remove all of it's categorisations, then the product will still be available (i.e. /product-one/) - and then just set it's stock options/layout to have a discontinued message.


4

I have got a success after long process/RND and searching on google a lot. $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('entity_id', (array) $orderId); foreach ($orders as $o) { //load order object - I know it's not ok to use load in a loop but it should be ok since it's ...


4

You first need to inject several classes in your constructor protected $_wishlistProviderInterface; protected $_itemFactory; public __construct( ... \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProviderInterface, \Magento\Wishlist\Model\ItemFactory $itemFactory ... ) { ... $this->_wishlistProviderInterface = $...


4

First, I suggest you try to avoid using the ObjectManager directly Second, I reckon you should use the \Magento\Catalog\Api\ProductRepositoryInterface service contrat to delete a product: protected $_productRepositoryInterface; public function __construct( ... \Magento\Catalog\Api\ProductRepositoryInterface $productRepositoryInterface, ... ...


4

Customer delete operation is valid from admin only. When you perform delete operation, magento check isSecureArea is true/false. So you can assign isSecureArea by following way: /** * @var \Magento\Framework\Registry */ protected $registry; /** * @param Context $context * @param PageFactory $resultPageFactory */ public function __construct( \...


4

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product'); $product->load($productID)->delete();


4

The mini cart items are from browser local storage. That means you need to reload the frontend cart section as well. An example here: https://magento.stackexchange.com/a/184745/33057


4

May be this code will help your logic : $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cartObject = $objectManager->create('Magento\Checkout\Model\Cart')->truncate(); $cartObject->saveQuote(); Remember that section is loaded after execution above code .


3

The urlDecodeAndEscape() method was added in version 1.9.1.0 Did you make a clean install with version 1.9.1.0 or did you an upgrade from an older Magento version. In case you made an upgrade check in /app/code/core/Mage/Core/Helper/Abstract.php on line 381 if the method urlDecodeAndEscape is available. Else I would suggest you make a fresh install with ...


3

You'll need to load them each individually, namely: Mage::getModel('sales/order')->load($order_id); Mage::getModel('sales/order_invoice')->load($invoice_id); Mage::getModel('sales/order_shipment')->load($shipment_id); Mage::getModel('sales/order_creditmemo')->load($creditmemo_id); The aforementioned ids are stored in the entity_id column of ...


3

Use Magmi so that you can do this by without any coding. Also product adding will be much easier and faster http://www.adrikodde.nl/blog/2013/how-delete-magento-products-magmi/


3

I got the solution. foreach ($collection as $key => $product) { if ($productStoreId != $currentStoreId) { $collection->removeItemByKey($key); } }


3

In addition to @mhauri's answer I'd like to add: Check your var/log directory if the system.log or exception.log files are big. You should have a look at the issues in there before you empty the files.


3

Tom,you need to upload product object by primary key.loadByAttribute() not capable for delete the product. $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $productSku); /* product exit then the prooduct will be deleted */ if($product->getId()): $id=$product->getId(); $product = Mage::getModel('catalog/...


3

use storeId instead of $stores like $model = Mage::getModel('core/store')->load($store->getId()); $model->delete(); load function will load current store in for loop with $store->getId() this is just pseudocode use should have to follow just checkout with detail code in mage library hope this will work for you.


Only top voted, non community-wiki answers of a minimum length are eligible