【发布时间】:2018-11-05 12:38:34
【问题描述】:
我想在一页的网格视图中显示所有产品图像,但由于有数千种产品,我想添加分页以获得更好的 UI。
下面是我在网格视图中显示图像的代码 -
<!DOCTYPE html>
<html>
<head>
<title>Images Grid View</title>
<style type="text/css">
#thumb {
clear : both;
width : 100%;
margin-left : 0;
}
#thumb ul {
width : 100%;
}
#thumb ul li {
display : inline;
font-family : arial;
float : left;
padding-right : 5px;
width: 210px;
height : 280px;
}
#thumb ul li img {
float : left;
width : 200px;
height : 200px;
border : #ccc solid 1px;
padding : 2px;
}
</style>
</head>
<body>
</body>
</html>
<?php
$rootPath = '/var/www/html/';
require_once $rootPath.'app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objManager = $bootstrap->getObjectManager();
$state = $objManager->get('\Magento\Framework\App\State');
$state->setAreaCode('frontend');
$resource = $objManager->get('\Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection('core_write');
$entity_ids = array(10,100,1000,1001,116962,112694,116049,116960);
foreach ($entity_ids as $entity_id) {
$oldImage = array();
$media_results = $connection->query("SELECT value_id from catalog_product_entity_media_gallery_value where entity_id ='".$entity_id."'")->fetchAll();
if(!empty($media_results)){
echo '<div id="thumb"><ul>';
foreach($media_results as $valueids){
$value_id = $valueids['value_id'];
$oldimg = $connection->fetchOne("select value from catalog_product_entity_media_gallery where value_id = '".$value_id."' limit 1");
$oldImage[] = $oldimg;
echo '<li><p>' . $entity_id .'</p>';
echo '<img src="https://testwebsite.com/pub/media/catalog/product/'.$oldimg.'" alt="Image" />';
echo '</li>';
}
echo '</ul></div>';
}
}
?>
图像在网格视图中正确显示,但我想添加分页以在每个页面上仅显示 3 个产品。
任何建议将不胜感激。
【问题讨论】:
标签: php jquery html angularjs ajax