Step 1 : Open magentoroot/app/etc/env.php
Step 2 : Find -> 'x-frame-options' => 'SAMEORIGIN',
Step 3 : Replace -> 'x-frame-options' => 'GOFORIT',
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Step 1 : Open magentoroot/app/etc/env.php
Step 2 : Find -> 'x-frame-options' => 'SAMEORIGIN',
Step 3 : Replace -> 'x-frame-options' => 'GOFORIT',
$registry = $objectManager->get('\Magento\Framework\Registry');
$registry->register('isSecureArea', true);
$removeproduct = $objectManager->create('\Magento\Catalog\Model\Product');
$removeproduct->load(21); / Product id
$removeproduct->delete();
I think its issue on Magento 2.2.3 or below version
Open root/app/code/Magento/Catalog/Model/ProductRepository.php
protected function processMediaGallery(ProductInterface $product, $mediaGalleryEntries)
{
find : if (isset($entry['value_id']) // near line no : 499 TO
if (isset($entry['value_id']) && $entry['value_id'] != '') {
}
$title = 'Apple Fritter E Juice 120ml By Loaded E Liquid';
$urltitle = str_replace(' ', '-', $title);
$urlkey = preg_replace("/[^a-zA-Z0-9]+/[^a-zA-Z0-9]+/", "", strtolower($urltitle));
echo $urlkey;
use Magento\Framework\App\Action\Context; class Createproduct extends \Magento\Framework\App\Action\Action { protected $directoryList; protected $file; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $pageFactory, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Framework\Filesystem\Io\File $file) { $this->_resultpageFactory = $pageFactory; $this->directoryList = $directoryList; $this->file = $file; return parent::__construct($context); } protected function getMediaDirTmpDir() { return $this->directoryList->getPath($this->directoryList::MEDIA) . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR; } public function setImage($product, $imageUrl, $visible = false, $imageType = []) { $tmpDir = $this->getMediaDirTmpDir(); $this->file->checkAndCreateFolder($tmpDir); $newFileName = $tmpDir . baseName($imageUrl); $result = $this->file->read($imageUrl, $newFileName); if ($result) { $product->addImageToMediaGallery($newFileName, $imageType, true, $visible); } return $result; } public function execute() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('\Magento\Catalog\Model\Product')->load(1); $imagePath = "https://domain.com/image.jpg"; // path of the image $this->setImage($product, $imagePath, false, $imageType = ['image', 'small_image', 'thumbnail']); $product->save(); } }
$imagePath = "https://jaydip.kansagra.com/image.jpg";
if (@getimagesize($imagePath)) {
echo 'Image exists';
} else {
echo 'Image not exists';
}
You do not set the weight before generation of children's products. Depending on this field the Magento decides what type of product is created.