SPARQL: Choose one triple from multiple match? Supplementation - limit

I have a query for updating my RDF database. The problem is that ?Terminal2 block of query is returning two different ?Terminal2's (both match the query) and that is making my code useless. I would need to somehow limit it for only one ?Terminal2 - doesn't matter which one. When I put this code to TopBraid, I get only one line in output so the LIMIT is working for the whole code not just for that subquery. Do you have any idea how to make my code working? There were some ideas about using SAMPLE. (I had opened similar question here.)
DELETE
{
?Terminal1 blb:Terminal.ConnectivityNode ?T2 .
}
INSERT
{
?Terminal1 blb:Terminal.ConnectivityNode ?T2_new .
?Terminal2 blb:used ?used .
?Terminal3 blb:used ?used .
?T2 blb:used ?used .
}
WHERE
{
?Terminal1 rdf:type blb:Terminal .
?Terminal1 blb:IdentifiedObject.name "T2" .
?Terminal1 blb:Terminal.ConnectivityNode ?T2 .
?Terminal1 blb:IdentifiedObject.description ?desc .
FILTER(?desc != "Evo") .
BIND(("Used") as ?used) .
{
select * WHERE
{
?Terminal2 rdf:type blb:Terminal .
?Terminal2 blb:IdentifiedObject.name "T2" .
?Terminal2 blb:IdentifiedObject.description "Evo" .
?Terminal2 blb:Terminal.ConductingEquipment ?Parent .
?Terminal2 blb:Terminal.ConnectivityNode ?T2 .
}
limit 1
}
?Terminal3 rdf:type blb:Terminal .
?Terminal3 blb:IdentifiedObject.name "T1" .
?Terminal3 blb:IdentifiedObject.description "Evo" .
?Terminal3 blb:Terminal.ConductingEquipment ?Parent .
?Terminal3 blb:Terminal.ConnectivityNode ?T2_new .
OPTIONAL
{
?T2 rdf:type blb:ConnectivityNode .
}
}
Thanks for help!
This code below works (exactly as I need) in TopBraid (with SELECT *), but not as DELETE/INSERT query. The error is
Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Encountered " <INTEGER> "1 "" at line 1, column 1040.
DELETE
{
?Terminal1 blb:Terminal.ConnectivityNode ?T2 .
}
INSERT
{
?Terminal1 blb:Terminal.ConnectivityNode ?T2_new .
?Terminal2 blb:used ?used .
?Terminal3 blb:used ?used .
?T2 blb:used ?used .
}
WHERE
{ ?Terminal1 rdf:type blb:Terminal .
?Terminal1 blb:IdentifiedObject.name "T2" .
?Terminal1 blb:Terminal.ConnectivityNode ?T2 .
?Terminal1 blb:IdentifiedObject.description ?desc .
FILTER(?desc != "EVO") .
BIND(("Used") as ?used) .
{
select ?Terminal2 (SAMPLE(?Parent2) AS ?Parent ) WHERE
{
?Terminal2 rdf:type blb:Terminal .
?Terminal2 blb:IdentifiedObject.name "T2" .
?Terminal2 blb:IdentifiedObject.description "EVO" .
?Terminal2 blb:Terminal.ConductingEquipment ?Parent2 .
?Terminal2 blb:Terminal.ConnectivityNode ?T2 .
}
GROUP BY ?Terminal2
LIMIT 1
}
?Terminal3 rdf:type blb:Terminal .
?Terminal3 blb:IdentifiedObject.name "T1" .
?Terminal3 blb:IdentifiedObject.description "EVO" .
?Terminal3 blb:Terminal.ConductingEquipment ?Parent .
?Terminal3 blb:Terminal.ConnectivityNode ?T2_new .
OPTIONAL{?T2 rdf:type blb:ConnectivityNode .}
}

Related

how to show all the products laravel

I have a query where I show all the products that are in that warehouse, but if it has more than one it shows me the x quantity but with the same data, thats because I have ->first(); but If I remove ->first(); it says an error whit the traceability.
$Input = $request->key;
$almacen = $request->almacen;
$name = DB::table('products')
->leftJoin('inventories', 'inventories.product_id', '=', 'products.id')
->whereRaw("(products.reference LIKE '%$Input%' OR products.name LIKE '%$Input%') AND products.deleted_at is null")
->leftJoin('warehouses', 'inventories.warehouse_id', '=', 'warehouses.id')
->where('warehouses.id', $almacen)
->whereNull('products.deleted_at')
->whereNull('inventories.deleted_at')
->select(
'products.reference',
'products.name',
'products.sku',
'products.id',
'inventories.lot',
'inventories.expirationDate',
'inventories.traceability',
'inventories.warehouse_id'
)
->get();
$array = [];
foreach ($name as $key) {
//$key->traceability
array_push($array, $key->reference);
}
//$array = array_unique($array);
$html = '';
if ($name != '[]') {
foreach ($array as $value) {
$prodName = DB::table('products')
->leftJoin('inventories', 'inventories.product_id', '=', 'products.id')
->where('products.reference', $value)
->whereNull('products.deleted_at')
->whereNull('inventories.deleted_at')
->select(
'products.reference',
'products.name',
'products.sku',
'products.id',
'inventories.lot',
'inventories.expirationDate',
'inventories.traceability'
)
->first();
//return $value;
$html .= '<div><a style="color: #000000" class="suggest-element" traceability="'.$prodName->traceability.'" reference="' . $value . '" sku="' . $prodName->sku . '" name="' . $prodName->name . '" lot="' . $prodName->lot . '" expirationDate="' . $prodName->expirationDate . '" data="' . ($value) . " " . ($prodName->name) . '" id="' . $prodName->id . '">' . ($value) . " " . ($prodName->name) ." " . ($prodName->lot) ." " . ($prodName->expirationDate) ." " . ($prodName->traceability) .'</a></div>';
}
} else {
$html .= '<div><a style="color: #000000" class="suggest-element" exist="0" data="Sin coincidencias." id="0">Sin coincidencias.</a></div>';
}
return $html;
});`
I would like to see the products whit the correct data,
Your code is currently only returning the first row in the database because you are using first().
If you remove first(), you will just be left with a Query Builder and will get an error like "Undefined property: Illuminate\Database\Query\Builder::$traceability" - because you haven't got the data yet.
You can use get() instead of first() to get all of the rows, and this will return a Collection.
You can also use ->whereIn('products.reference', $array) instead of looping through all of the elements in $array
You are also comparing $name to the string '[]' instead of an empty array. You can use empty() instead: if (!empty($name)) {
And then you can simply loop through the Collection and add the html:
// Use empty() - This checks if an array is empty or not
if (!empty($name)) {
$products = DB::table('products')
->leftJoin('inventories', 'inventories.product_id', '=', 'products.id')
// Use whereIn - This checks if any of the values in $array match products.reference
->whereIn('products.reference', $array)
->whereNull('products.deleted_at')
->whereNull('inventories.deleted_at')
->select(
'products.reference',
'products.name',
'products.sku',
'products.id',
'inventories.lot',
'inventories.expirationDate',
'inventories.traceability'
)
// Return all rows
->get();
foreach ($products as $product) {
$html .= '<div><a style="color: #000000" class="suggest-element" traceability="' . $product->traceability . '" reference="' . $product->reference . '" sku="' . $product->sku . '" name="' . $product->name . '" lot="' . $product->lot . '" expirationDate="' . $product->->expirationDate . '" data="' . ($product->reference) . " " . ($product->->name) . '" id="' . $product->->id . '">' . ($product->reference) . " " . ($product->name) . " " . ($product->lot) . " " . ($product->expirationDate) . " " . ($product->traceability) . '</a></div>';
}
} else {

How to add dynamic sum total [Footer] to an array column in laravel excel version 3.1?

I'm using this reference here > https://docs.laravel-excel.com/3.1/exports/collection.html
I use version 3.1 of Maatwebsite to map the data and extract it via excel file.
This is my controller function to export the data with.
public function exportTestData(Request $request)
{
$timestamp = Carbon::now()->toDateTimeString();
$filename = "act-data-({$timestamp}).xlsx";
// getActData >> the function of the sql raw query
return Excel::download(new TestDataExport($this->getActData($request, true)), $filename);
}
And it produces this output:
Question:
How do I add a dynamic data that totals the summary of Sales, Income, Both vertically.
I want a desired output like this:
So basically a custom data that totals the summary and add in dynamically after the end of each array. My Total function array assign to cell H2 totals the data horizontally. How to total each data vertically in this kind of integration. Trying to find any reference to stackoverflow, laracasts, and github but I can't find any good resources to start with.
Can somebody help me with this situation? Thanks.
Here's the full code of my export function to understand the coding process.
TestDataExport.php
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
class TestDataExport implements FromCollection, ShouldAutoSize, WithCustomStartCell, WithHeadings, WithTitle, WithEvents
{
use Exportable;
/**
* testDatas.
*
* #var string
*/
protected $actData;
public function __construct($testDatas)
{
$this->testDatas = $testDatas;
}
public function startCell(): string
{
return 'A2';
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
/** #var Sheet $sheet */
$sheet = $event->sheet;
// map header data to this cells
$sheet->mergeCells('E1:H1');
$sheet->setCellValue('E1', "Summaries");
$styleArray = [
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
],
];
$cellRange = 'A1:X1'; // All headers center align
$event->sheet->getDelegate()->getStyle($cellRange)->applyFromArray($styleArray);
},
];
}
/**
* #return \Illuminate\Support\Collection
*/
public function collection()
{
$testDatas = $this->testDatas;
if (isset($testDatas)) {
return collect($testDatas)->map(function ($actData, $key) {
//define totals
$totals = ! empty($actData['Summaries']) ? $actData['Summaries']['total'] : '0';
return [
'sales' => ! empty($actData['Summaries']) ? $actData['Summaries']['sales'] : '0',
'income' => ! empty($actData['Summaries']) ? $actData['Summaries']['income'] : '0',
'both' => ! empty($actData['Summaries']) ? $actData['Summaries']['both'] : '0',
'total' => ! empty($totals) ? $totals : '0',
];
});
}
return collect([]);
}
/**
* Heading of the excel
*
* #return array
*/
public function headings(): array
{
return [
'Sales',
'Income',
'Both',
'Total',
];
}
/**
* Title for each sheet
*
* #return string
*/
public function title(): string
{
return 'Test Data Export';
}
}
UPDATE
I'm using this inside my registerEvents function.
//calculate totals
$sheet->setCellValue('V'. ($sheet->getHighestRow()+1), '=SUM(V3:V'.$sheet->getHighestRow().')');
$sheet->setCellValue('W'. ($sheet->getHighestRow()+1), '=SUM(W3:W'.$sheet->getHighestRow().')');
$sheet->setCellValue('X'. ($sheet->getHighestRow()+1), '=SUM(X3:X'.$sheet->getHighestRow().')');
$sheet->setCellValue('Y'. ($sheet->getHighestRow()+1), '=SUM(Y3:Y'.$sheet->getHighestRow().')');
It's giving me the total value of each rows, but I'm also having a problem. Everytime I added a new total to each row. The total will be incremented by 1.
Output here:
Is there anyway to revamp the code without incrementing it by 1? As of now it will jump from one cell to another
Managed to solve this one using the styles function
public function styles(Worksheet $sheet)
{
$styleArray = [
'font' => [
'bold' => true,
'color' => ['rgb' => 'FF0000'],
]];
$sheet->setCellValue('D' . ($sheet->getHighestRow()+1), 'TOTALS')->getStyle('D' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
// Add cell with SUM formula to last row
$sheet->setCellValue('E' . ($sheet->getHighestRow()+0), '=SUM(E2:E' . ($sheet->getHighestRow()-1) . ')')->getStyle('E' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('F' . ($sheet->getHighestRow()+0), '=SUM(F2:F' . ($sheet->getHighestRow()-1) . ')')->getStyle('F' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('G' . ($sheet->getHighestRow()+0), '=SUM(G2:G' . ($sheet->getHighestRow()-1) . ')')->getStyle('G' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('H' . ($sheet->getHighestRow()+0), '=SUM(H2:H' . ($sheet->getHighestRow()-1) . ')')->getStyle('H' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('I' . ($sheet->getHighestRow()+0), '=SUM(I2:I' . ($sheet->getHighestRow()-1) . ')')->getStyle('I' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('J' . ($sheet->getHighestRow()+0), '=SUM(J2:J' . ($sheet->getHighestRow()-1) . ')')->getStyle('J' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('K' . ($sheet->getHighestRow()+0), '=SUM(K2:K' . ($sheet->getHighestRow()-1) . ')')->getStyle('K' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('L' . ($sheet->getHighestRow()+0), '=SUM(L2:L' . ($sheet->getHighestRow()-1) . ')')->getStyle('L' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('M' . ($sheet->getHighestRow()+0), '=SUM(M2:M' . ($sheet->getHighestRow()-1) . ')')->getStyle('M' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('N' . ($sheet->getHighestRow()+0), '=SUM(N2:N' . ($sheet->getHighestRow()-1) . ')')->getStyle('N' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('O' . ($sheet->getHighestRow()+0), '=SUM(O2:O' . ($sheet->getHighestRow()-1) . ')')->getStyle('O' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('P' . ($sheet->getHighestRow()+0), '=SUM(P2:P' . ($sheet->getHighestRow()-1) . ')')->getStyle('P' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('Q' . ($sheet->getHighestRow()+0), '=SUM(Q2:Q' . ($sheet->getHighestRow()-1) . ')')->getStyle('Q' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('R' . ($sheet->getHighestRow()+0), '=SUM(R2:R' . ($sheet->getHighestRow()-1) . ')')->getStyle('R' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('S' . ($sheet->getHighestRow()+0), '=SUM(S2:S' . ($sheet->getHighestRow()-1) . ')')->getStyle('S' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('T' . ($sheet->getHighestRow()+0), '=SUM(T2:T' . ($sheet->getHighestRow()-1) . ')')->getStyle('T' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('U' . ($sheet->getHighestRow()+0), '=SUM(U2:U' . ($sheet->getHighestRow()-1) . ')')->getStyle('U' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('V' . ($sheet->getHighestRow()+0), '=SUM(V2:V' . ($sheet->getHighestRow()-1) . ')')->getStyle('V' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('W' . ($sheet->getHighestRow()+0), '=SUM(W2:W' . ($sheet->getHighestRow()-1) . ')')->getStyle('W' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('X' . ($sheet->getHighestRow()+0), '=SUM(X2:X' . ($sheet->getHighestRow()-1) . ')')->getStyle('X' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('Y' . ($sheet->getHighestRow()+0), '=SUM(Y2:Y' . ($sheet->getHighestRow()-1) . ')')->getStyle('Y' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('Z' . ($sheet->getHighestRow()+0), '=SUM(Z2:Z' . ($sheet->getHighestRow()-1) . ')')->getStyle('Z' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('AA' . ($sheet->getHighestRow()+0), '=SUM(AA2:AA' . ($sheet->getHighestRow()-1) . ')')->getStyle('AA' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('AB' . ($sheet->getHighestRow()+0), '=SUM(AB2:AB' . ($sheet->getHighestRow()-1) . ')')->getStyle('AB' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
$sheet->setCellValue('AC' . ($sheet->getHighestRow()+0), '=SUM(AC2:AC' . ($sheet->getHighestRow()-1) . ')')->getStyle('AC' . ($sheet->getHighestRow()))->applyFromArray($styleArray);
}
In the first CellValue which is D this one will increment the last data and add it just right below to compute the totals.
For the following E > AC when I try to use $sheet->getHighestRow()+1) for each setCellValue the data is incremented after every cell column. I tried experimenting it but it seems when you add $sheet->getHighestRow()+0) on cell E > AC it will be then placed the totals of each column. Don't know why, maybe some of you can find and alternative or a better way for this one.

How can I solve File not found at path:... when rename file? (laravel)

I see from here : rename a directory or a file
I try like this :
$destination_path = public_path() . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'products'. DIRECTORY_SEPARATOR . $product->id . DIRECTORY_SEPARATOR . $product->photo;
$new_file_name = public_path() . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'products'. DIRECTORY_SEPARATOR . $product->id . DIRECTORY_SEPARATOR . $new_file_name;
// dd($destination_path, $new_file_name);
Storage::move($destination_path, $new_file_name);
There exist error :
[League\Flysystem\FileNotFoundException] File not found at path:
C:/xampp/htdocs/myshop/public/img/products/147/Zl756CDHovOZpEZz0jBYk73UCfO4zNmYDVWgLPpw.png
If I dd($destination_path, $new_file_name), the result :
C:\xampp\htdocs\myshop\public\img\products\147\Zl756CDHovOZpEZz0jBYk73UCfO4zNmYDVWgLPpw.png
C:\xampp\htdocs\myshop\public\img\products\147\147-hazard-chelsea.png
I try check Zl756CDHovOZpEZz0jBYk73UCfO4zNmYDVWgLPpw.png in folder 147, the file exist
Why there exist error?
Update :
I had find the solution. I use php script like this :
rename($destination_path, $new_file_name);. It works
Storage use C:/xampp/htdocs/myshop/storage/app
but your data store on public path
you can use \Storage::exists($path);
$destination_path = public_path() . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'products'. DIRECTORY_SEPARATOR . $product->id . DIRECTORY_SEPARATOR . $product->photo;
$new_file_name = public_path() . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'products'. DIRECTORY_SEPARATOR . $product->id . DIRECTORY_SEPARATOR . $new_file_name;
// dd($destination_path, $new_file_name);
if(\Storage::exists($destination_path)){
Storage::move($destination_path, $new_file_name);
}

PHP Session not getting updated in FireFox

I am facing a strange error. It is related to updating the php session.
I have a site whose login/logout works perfectly in chrome,safari and IE etc. But in firefox it is not working. When I login using firefox, the logout button seems to be dead or something. It just doesnt let me logout. Even if I manually type the logout link, it still doesnt do anything and keeps me logged in. I am not doing anything complex at all.
Any ideas why the same code works in chrome, IE and safari but not in firefox?
Let me know,
Thanks.
============================LOGOUT CODE===============================
public function logout() {
$this->session->unset_userdata('smallpoint_username');
$this->session->sess_destroy();
redirect(base_url() . 'forum/update_session.php?hasher = ' . time() . time() . time() . time() . time() . time() . '&&nohasher=' . time() . time() . time() . time() . time() . time() . '&&op=2', 'location', 301);
}
================SESSION SETTING CODE in LOGIN===============================
$session_array = array(
'smallpoint_username' => $insertData['username'],
'smallpoint_full_name' => $insertData['full_name'],
'smallpoint_user_type' => $insertData['user_type'],
'smallpoint_user_id' => $userData['id'],
'smallpoint_user_snap' => '',
'is_logged_in' => 1,
);
$this->session->set_userdata($session_array);
redirect(base_url() . 'forum/update_session.php?hasher = ' . time() . time() . time() . time() . time() . time() . '&&nohasher=' . time() . time() . time() . time() . time() . time() . '&&thisisid=' . $userData['id'] . '&&thisisrole=' . $insertData['role'] . '&&thisisname=' . $insertData['username'] . '&&op=1', 'location', 301);
=====================update_session.php======================
session_start();
require 'includes.php';
if ($_GET['op'] == 1) {
$_SESSION[TABLES_PREFIX . 'sforum_logged_in'] = true;
$_SESSION[TABLES_PREFIX . 'sforum_user_id'] = $_GET['thisisid'];
$_SESSION[TABLES_PREFIX . 'sforum_user_role'] = $_GET['thisisrole'];
$_SESSION[TABLES_PREFIX . 'sforum_user_username'] = $_GET['thisisname'];
} else {
unset($_SESSION[TABLES_PREFIX . 'sforum_logged_in']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_id']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_role']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_username']);
setcookie(TABLES_PREFIX . COOKIE_NAME, "", time() - 3600);
}
header('Location: ' . $_SERVER['HTTP_REFERER']);
Try to add the following to your code.
session_save_path("/tmp");
session_start();
I got the same problem in firefox and it works fine
session_save_path("/tmp"); // CREATE this Folder in the root
session_start();
require 'includes.php';
if ($_GET['op'] == 1) {
$_SESSION[TABLES_PREFIX . 'sforum_logged_in'] = true;
$_SESSION[TABLES_PREFIX . 'sforum_user_id'] = $_GET['thisisid'];
$_SESSION[TABLES_PREFIX . 'sforum_user_role'] = $_GET['thisisrole'];
$_SESSION[TABLES_PREFIX . 'sforum_user_username'] = $_GET['thisisname'];
} else {
unset($_SESSION[TABLES_PREFIX . 'sforum_logged_in']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_id']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_role']);
unset($_SESSION[TABLES_PREFIX . 'sforum_user_username']);
setcookie(TABLES_PREFIX . COOKIE_NAME, "", time() - 3600);
}
header('Location: ' . $_SERVER['HTTP_REFERER']);

Can We give the Code Pool Outside the "code" Directory in Magento

Can We give the Code Pool Outside the "code" Directory in Magento like
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('BP', dirname(dirname(__FILE__)));
Mage::register('original_include_path', get_include_path());
//echo get_include_path();
//die('This is included path');
if (defined('COMPILER_INCLUDE_PATH')) {
$appPath = COMPILER_INCLUDE_PATH;
set_include_path($appPath . PS . Mage::registry('original_include_path'));
include_once COMPILER_INCLUDE_PATH . DS . "Mage_Core_functions.php";
include_once COMPILER_INCLUDE_PATH . DS . "Varien_Autoload.php";
} else {
/**
* Set include path
*/
$paths[] = BP . DS . 'app' . DS . 'custom' . DS . 'custom';
/* 'custom' is My own folder name present out side the code directory */
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';
$appPath = implode(PS, $paths);
set_include_path($appPath . PS . Mage::registry('original_include_path'));
include_once "Mage/Core/functions.php";
include_once "Varien/Autoload.php";
}
it is Not working for me. is there any method to put the codepool out side the "Code" Directory in magento.
You can have your custom codepool by putting below line in your app/Mage.php
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'custom';
that I expect that you already know.
But if you want to keep your codepool in app/custom then creating symlink for your codepool will be the easiest way. Infect you can place your codepool anywhere in your system.
This is how you will create your symlink(considering /home/deependra/public_html is your magento root directory)
ln -s /home/deependra/public_html/app/custom/custom/ /home/deependra/public_html/app/code/custom

Resources