当前位置: 首页 > news >正文

网页设计图片为什么显示不出来seo招聘要求

网页设计图片为什么显示不出来,seo招聘要求,html网页的基本结构,wordpress 雅黑图片包给的图片文件是子产品的图片&#xff0c;如下图&#xff1a;A104255是主产品的sku <?php/*** 根据图片包导入产品图片&#xff0c;包含子产品和主产品* 子产品是作为主图&#xff0c;主产品是作为附加图片*/use Magento\Framework\App\Bootstrap;include(../app/boot…

图片包给的图片文件是子产品的图片,如下图:A104255是主产品的sku

<?php/*** 根据图片包导入产品图片,包含子产品和主产品* 子产品是作为主图,主产品是作为附加图片*/use Magento\Framework\App\Bootstrap;include('../app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\App\ResourceConnection $resource */
$resource = $objectManager->get('\Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);$directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList');$obj = $bootstrap->getObjectManager();$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('adminhtml');/** @var  \Magento\Catalog\Model\ProductFactory $productFactory */
$productFactory = $objectManager->create('\Magento\Catalog\Model\ProductFactory');/** @var  \Magento\Catalog\Model\ResourceModel\MediaImageDeleteProcessor $mediaImageDeleteProcessor */
$mediaImageDeleteProcessor = $objectManager->create('\Magento\Catalog\Model\ResourceModel\MediaImageDeleteProcessor');$imageFolder = $directory->getRoot().'/pub/media/images_import';
$delUrl = $directory->getRoot().'/pub/media/catalog/product';$existsSku = [];try {// 指定搜索的文件夹和文件名进行搜索$folder = $imageFolder;//$fileName = $sku;$fileName = '*.jpg';// 执行搜索并获取结果数组$imgfiles = searchImagesInFolder($folder, $fileName);//print_r($imgfiles);die;if ($imgfiles) {foreach ($imgfiles as $imgfile) {try {$mainImagePath = $imgfile;if(is_file($mainImagePath)){$pathArr = explode('/', $mainImagePath);$imgName = end($pathArr);$sku = explode('.', $imgName)[0];if (in_array($sku, $existsSku)) continue;//if ($sku != 'B302170-5g') continue;//var_dump($sku);die;$sql = $connection->select()->from('catalog_product_entity')->where('sku = ?', $sku);$row = $connection->fetchRow($sql);if (!$row) {echo $sku,' 不存在',PHP_EOL;continue;}$product = $productFactory->create()->loadByAttribute('sku',$sku);$rowId = $product->getRowId();if (strstr($sku, '-')){ #主图#删除原有的图片/*$del = $connection->fetchAll("SELECT * from catalog_product_entity_media_gallery where value_id in( select value_id from catalog_product_entity_media_gallery_value_to_entity where row_id='{$rowId}')");foreach ($del as $key=>$value){if (file_exists($delUrl.'/'.$value['value'])) {unlink($delUrl . '/' . $value['value']);}}# 删除产品和图片的关联关系$connection->query("delete from catalog_product_entity_media_gallery where value_id in( select value_id from catalog_product_entity_media_gallery_value_to_entity where row_id='{$rowId}')");$connection->query("delete from catalog_product_entity_media_gallery_value_to_entity where row_id='{$rowId}'");$connection->query("delete from catalog_product_entity_varchar where row_id='{$rowId}' and attribute_id in(87,88,89)");*/echo $sku,' 主图',PHP_EOL;$product->setStoreId(0)->addImageToMediaGallery($mainImagePath, array('image', 'small_image', 'thumbnail'), false, false);}$product->save();#作为主产品的附加图$sku_master = explode('-', $sku)[0] ?? '';
//                    var_dump($sku_master);die;if (!$sku_master) continue;if (in_array($sku_master, $existsSku)) continue;$sql = $connection->select()->from('catalog_product_entity')->where('sku = ?', $sku_master);$row = $connection->fetchRow($sql);if (!$row) {echo $sku_master,' 不存在',PHP_EOL;continue;}$product_master = $productFactory->create()->loadByAttribute('sku',$sku_master);$rowId = $product_master->getRowId();#主产品导完删除图片$product_master->setStoreId(0)->addImageToMediaGallery($mainImagePath, [], true, false);$product_master->save();echo $sku_master,' 子图',PHP_EOL;}else{echo $sku." skip\n";}} catch (\Exception $e){throw new Exception($e->getMessage());}}} else {echo "没有找到匹配的文件。",PHP_EOL;}} catch (\Exception $e){echo $e->getMessage(),PHP_EOL;
}
//    }
//}function searchImagesInFolder($folder, $fileName)
{// 检查文件夹是否存在if (!is_dir($folder)) {return [];}// 初始化结果数组$result = [];// 打开文件夹$handle = opendir($folder);// 遍历文件夹中的文件和子文件夹while (($file = readdir($handle)) !== false) {if ($file != '.' && $file != '..') {$path = $folder . DIRECTORY_SEPARATOR . $file;// 如果是文件夹,则递归调用自身进行进一步搜索if (is_dir($path)) {$result = array_merge($result, searchImagesInFolder($path, $fileName));} else {// 如果是图片文件并且文件名与模糊匹配成功,则将文件路径添加到结果数组中if (isImageFile($file) && fnmatch("*{$fileName}*", $file)) {$result[] = $path;}}}}// 关闭文件夹closedir($handle);return $result;
}// 检查文件是否为图片文件
function isImageFile($file)
{$imageExtensions = ["jpg", "jpeg", "png", "gif"];$fileExtension = pathinfo($file, PATHINFO_EXTENSION);return in_array($fileExtension, $imageExtensions);
}

http://www.hkea.cn/news/48877/

相关文章:

  • 外贸五金网站建设网站制作优化排名
  • 义乌网站建设多少钱网络平台营销
  • 怀仁有做网站的公司吗磁力搜索引擎2023
  • 建站行业都扁平化设计合肥网站推广公司哪家好
  • 做企业网站织梦和wordpress哪个好百度指数查询工具app
  • 郑州网站服务公司优化神马排名软件
  • 茶叶网站建设的优势南宁seo外包平台
  • 高古楼网站 做窗子北京seo技术交流
  • 南阳建设网站制作网络最有效的推广方法
  • 纯静态网站seoseo排名优化北京
  • 开封网站建设哪家好指数计算器
  • 网站开发 架构石家庄seo关键词排名
  • 可以免费做商业网站的cms百度seo霸屏软件
  • 哪家网站建设专业快速建站教程
  • 坪山网站建设行业现状优化seo方案
  • 做网站需要架构师吗网站平台有哪些
  • 网站建设丿选择金手指15凡科建站官网
  • 可以做外国网站文章武汉企业seo推广
  • 天津网站建设公司最好太原做网站哪家好
  • 网站代下单怎么做百度指数数据分析平台入口
  • 淘宝做动效代码的网站seo的优化方向
  • 番禺建网站公司网站搜索工具
  • 安徽万振建设集团网站长春网站推广公司
  • 网站怎么制作 推广seo超级外链工具免费
  • 中小学网站建设探讨东莞seo整站优化火速
  • php是网站开发的语言吗企业网站的作用
  • 网站站外优化怎么做企业推广app
  • 拉趣网站是谁做的威海网站制作
  • 做宣传海报的网站百度导航2023年最新版
  • 湖南做网站 磐石网络windows优化大师官方免费