Skip to content

Instantly share code, notes, and snippets.

@vanilla-thunder
vanilla-thunder / [PHP Storm template] OXID metadata.php
Last active August 29, 2015 13:57
PhpStorm File Template for module metadata.php
<?php
/**
* MODULE-NAME
* Copyright (C) ${YEAR} ${USER}
* info: info@your-company.com
*
* This program is free software;
* you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
* either version 3 of the License, or (at your option) any later version.
*
@vanilla-thunder
vanilla-thunder / [PHP Storm tempalte] OXID custom admin view
Last active August 29, 2015 13:57
PhpStorm File Template for OXID custom admin view class
<?php
/**
* ${NAME}.php
* Copyright (C) ${YEAR} ${USER}
* info: info@your-company.com
*
* This program is free software;
* you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
* either version 3 of the License, or (at your option) any later version.
*
@vanilla-thunder
vanilla-thunder / [PHP Storm template] OXID class extension
Last active August 29, 2015 13:57
PhpStorm File Template for OXID modules: php class extension
<?php
/**
* ${NAME}.php
* Copyright (C) ${YEAR} ${USER}
* info: info@your-company.com
*
* This program is free software;
* you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
* either version 3 of the License, or (at your option) any later version.
*
@vanilla-thunder
vanilla-thunder / custom log + backtrace
Created February 5, 2014 09:47
[OXID eShop] custom log + function backtrace
$e = new Exception();
oxRegistry::getUtils()->writeToLog(var_export($aData, true)."\n","yolo.log");
oxRegistry::getUtils()->writeToLog($e->getTraceAsString()."\n------------------------------\n","yolo.log");
@vanilla-thunder
vanilla-thunder / clear template cache
Created May 8, 2013 10:11
[OXID eShop] clearing template cache in php
$cfg = oxRegistry::get("oxConfig");
$dir = $cfg->getConfigParam("sCompileDir") . "smarty/*";
foreach (glob($dir) as $item) {
if (!is_dir($item)) {
unlink($item);
}
}
@vanilla-thunder
vanilla-thunder / create CMS page
Created May 8, 2013 10:11
[OXID eShop] create/update CMS page by using shop framework
$aParams = array(
'oxcontents__oxid' => 'hdinotificationactplain', // OXID
'oxcontents__oxloadid' => 'hdi_notification_act_plain', // ident
'oxcontents__oxtitle' => 'Konto wieder aktiv PLAIN', // title
'oxcontents__oxcontent' => 'here comes the content', // content
'oxcontents__oxactive' => 1,
'oxcontents__oxtype' => 3, // 0 = snippet, 1 = mainmenu, 2 = category, 3 = manual
'oxcontents__oxsnippet' => 0,
'oxcontents__oxfolder' => 'CMSFOLDER_USERINFO',
'oxcontents__oxshopid' => oxSession::getVar("actshop"),
@vanilla-thunder
vanilla-thunder / check if a table exists
Created May 8, 2013 09:57
[OXID eShop] check if a table exists or not, e.g. for module activation / deactivation events
$oDb = oxDb::getDb();
$sCheck = "SHOW TABLES LIKE 'tablename'";
// returns string if table found or false if not found
if (!$oDb->getOne($sCheck))
{
// table does not exists
// do something
}
@vanilla-thunder
vanilla-thunder / updating DB Views
Last active December 17, 2015 02:59
[OXID eShop] updating DB Views
$oMetaData = oxNew('oxDbMetaDataHandler');
$oMetaData->updateViews();
@vanilla-thunder
vanilla-thunder / check if a column exists
Last active December 17, 2015 02:58
[OXID eShop] check if a table column exists, e.g. for module activatin / deactivation events
$oDb = oxDb::getDb();
$oRs = $oDb->metaColumnNames("tablename");
// check for lower case and upper case column name
if (!array_key_exists("columnname", $oRs) && !array_key_exists("COLUMNNAME", $oRs)) {
{
// column does not exists
// do something
}