Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (35 sloc) 928 Bytes
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\commerce\elements\actions;
use Craft;
use craft\elements\actions\Delete;
use craft\elements\db\ElementQueryInterface;
/**
* Delete Element Action
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 2.0
*/
class DeleteProduct extends Delete
{
// Public Methods
// =========================================================================
/**
* @inheritdoc
*/
public function performAction(ElementQueryInterface $query = null): bool
{
if (!$query) {
return false;
}
foreach ($query->all() as $product) {
Craft::$app->getElements()->deleteElement($product);
}
$this->setMessage(Craft::t('commerce', 'Products deleted.'));
return true;
}
}
You can’t perform that action at this time.