EC-CUBEカスタマイズ †バージョン: EC-CUBE ver3
css/jsファイル追加 †css/jsファイル作成 †以下のディレクトリ配下に作成する 以下、custom.css 及び custom.js を追加する場合の例だが、
css/jsファイルを読み込むように default_frame.twig を修正する †以下のファイルに link 及び script タグを追加。
会員登録をスキップする †購入時の会員ログイン画面をスキップ †src/Eccube/Controller/CartController.php public function buystep(Application $app, Request $request)
{
.
.
//return $app->redirect($app->url('shopping'));
return $app->redirect($app->url('shopping_nonmember'));
}
src/Eccube/Controller/ShoppingController.php /**
* 購入画面表示
*
* @param Application $app
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
*/
public function index(Application $app, Request $request)
{
.
.
if (is_null($Customer)) {
// 会員登録スキップ
return $app->redirect($app->url('shopping_nonmember'));
//log_info('未ログインのためログイン画面にリダイレクト');
//return $app->redirect($app->url('shopping_login'));
}
.
.
.
/**
* ログイン
*/
public function login(Application $app, Request $request)
{
// 会員管理しないため、ログインはスキップ
return $app->redirect($app->url('shopping'));
/*
if (!$app['eccube.service.cart']->isLocked()) {
.
.
*/
Controllerを追加する †以下、新着商品の一覧を表示するブロックコントローラを追加する例を記載する。 ルーティング追加 †src/Eccube/ControllerProvider/FrontControllerProvider.php .
.
$c->match('/block/newitems', '\Eccube\Controller\Block\NewItemsController::index')->bind('block_new_items');
コントローラ追加 †コントローラからデータベースを読む際には、ORマッパーとしてDoctrineが利用できる。 src/Eccube/Controller/Block/NewItemsController.php <?php
namespace Eccube\Controller\Block;
use Eccube\Application;
use Doctrine\ORM\Query\ResultSetMapping;
class NewItemsController
{
public function index(Application $app)
{
$newItems = $this->selectNewItems($app['orm.em']);
return $app->render('Block/new_items.twig', array(
'NewItems' => $newItems,
));
}
private function selectNewItems($em)
{
$sql = 'SELECT t1.product_id, t1.name, t1.description_detail, t2.file_name
FROM dtb_product t1
left outer join
dtb_product_image t2 on t1.product_id = t2.product_id
WHERE t1.del_flg = 0 and t1.status = 1
ORDER BY t1.create_date desc, t1.product_id
LIMIT 12';
$rsm = new ResultSetMapping();;
$rsm->addScalarResult('product_id', 'product_id');
$rsm->addScalarResult('name', 'name');
$rsm->addScalarResult('description_detail', 'description_detail');
$rsm->addScalarResult('file_name', 'file_name');
$query = $em->createNativeQuery($sql, $rsm);
$result = $query->getResult();
$items = array();
$preId = null;
foreach ($result as $row) {
if ($preId != $row["product_id"]) {
$items[] = $row;
}
$preId = $row["product_id"];
}
return $items;
}
}
ブロックをincludeする †静的ブロックの場合 †{{ include('Block/sample1.twig', ignore_missing = true) }}
動的ブロックの場合 †動的ブロックの場合は controller を通過させる必要がある為、FrontControllerProvider にルーティングを追加後、以下の通り記載する。 {{ render(path('block_new_items')) }}
注文番号を連番以外にする †TODO:
src/Eccube/Controller/ShoppingController.php // TODO: src/Eccube/Service/ShoppingService.php // TODO: src/Eccube/Service/MailService.php // TODO: src/Eccube/Resource/template/default/Shopping/complete.twig // TODO: src/Eccube/Resource/template/default/Mail/order.twig // TODO: |