Reflection Added to db but file does not exit - impresspages

File is relative to /file/repository/AutoSalon/hasi/BB_Light_House_8.png
ipFileUrl(ipReflection('AutoSalon/'.$user['username'].'/'.$value['photo1'],$opti‌​ons,'thumb_'.$value['photo1'],true));
(36, options ,fprit, 'AutoSalon/hasi/BB_Light_House_8.png', '2016/02/03/thumb_BB_Light_House_8.png', 1454520313);
BUT there is no File in /file/2016/02/03/thumb_BB_Light_House_8.png
GET http://kukur.dev/file/2016/02/03/thumb_BB_Light_House_8_1.png 404 (Not Found)
Here is LOG FILE
{"errorTrace":"#0 /Users/flakerimi/Sites/ImpressPages/Ip/Internal/Repository/ReflectionModel.php(60): Ip\Internal\Repository\ReflectionModel->createReflectionRecord('AutoSalon/hasi/', Array, NULL)\n#1 /Users/flakerimi/Sites/ImpressPages/Ip/Internal/Repository/ReflectionService.php(84): Ip\Internal\Repository\ReflectionModel->getReflection('AutoSalon/hasi/', Array, NULL, true)\n#2 /Users/flakerimi/Sites/ImpressPages/Ip/Functions.php(957): Ip\Internal\Repository\ReflectionService->getReflection('AutoSalon/hasi/', Array, NULL, true)\n#3 /Users/flakerimi/Sites/ImpressPages/Plugin/AutoSalon/view/user/list.php(25): ipReflection('AutoSalon/hasi/', Array)\n#4 /Users/flakerimi/Sites/ImpressPages/Ip/View.php(111): require('/Users/flakerim...')\n#5 /Users/flakerimi/Sites/ImpressPages/Ip/Application.php(352): Ip\View->render()\n#6 /Users/flakerimi/Sites/ImpressPages/Ip/Application.php(442): Ip\Application->handleRequest(Object(Ip\Request), Array, false)\n#7 /Users/flakerimi/Sites/ImpressPages/Ip/script/run.php(8): Ip\Application->run()\n#8 /Users/flakerimi/Sites/ImpressPages/index.php(14): require_once('/Users/flakerim...')\n#9 {main}"}

Just for Archive purpose:
Problem was with $options,
$options = array('type' => 'center', 'widht' => 400, 'height'=>200, 'forced' => true);
There is a typo at Width (widht) and thats why. Maybe some better check on that ?

Related

Prestashop 1.7.7. Error When Proceed to Checkout

Like I explain at the title this issue it's related with the checkout of prestashop version 1.7.7.0.
When I add I product to the cart, and then I press the button to proceed to the checkout I have this issue:
[21-Jun-2021 22:39:57 Europe/Madrid] PHP Fatal error: Uncaught Error: Call to undefined method Cart::checkAllProductsAreStillAvailableInThisState() in /home/public_html/classes/checkout/CheckoutPaymentStep.php:48
Stack trace:
#0 /home/public_html/classes/checkout/CheckoutProcess.php(59): CheckoutPaymentStepCore->handleRequest(Array)
#1 /home/public_html/controllers/front/OrderController.php(278): CheckoutProcessCore->handleRequest(Array)
#2 /home/public_html/classes/controller/Controller.php(306): OrderControllerCore->initContent()
#3 /home/public_html/classes/Dispatcher.php(518): ControllerCore->run()
#4 /home/public_html/index.php(28): DispatcherCore->dispatch()
#5 {main}
thrown in /home/public_html/classes/checkout/CheckoutPaymentStep.php on line 48
I have made some test:
Disable all the modules and have only to the native ones of Prestashop.
Tried with a clean install and always i have the same problem.
No matters if it's the default theme or the bought one.
Delete the cache of prestashop...
Clearly i'm desesperate with this problem... Any help will be so apreciate.
Hello again for all the community,
I have solve the problem by commenting some lines of code.
Get this archive and edit it.
Classes > Checkout > CheckoutPaymentStep.php
public function handleRequest(array $requestParams = [])
{
$cart = $this->getCheckoutSession()->getCart();
$allProductsInStock = $cart->isAllProductsInStock();
//$allProductsExist = $cart->checkAllProductsAreStillAvailableInThisState(); /*-- Comment this --*/
//$allProductsHaveMinimalQuantity = $cart->checkAllProductsHaveMinimalQuantities(); /*-- Comment this --*/
//if ($allProductsInStock !== true || $allProductsExist !== true || $allProductsHaveMinimalQuantity !== true) /*-- Change this one --*/
if ($allProductsInStock !== true) {
$cartShowUrl = $this->context->link->getPageLink(
'cart',
null,
$this->context->language->id,
[
'action' => 'show',
],
false,
null,
false
);
Tools::redirect($cartShowUrl);
}
if (isset($requestParams['select_payment_option'])) {
$this->selected_payment_option = $requestParams['select_payment_option'];
}
$this->setTitle(
$this->getTranslator()->trans(
'Payment',
[],
'Shop.Theme.Checkout'
)
);
}
For now all goes well and we can process to the checkout. Hope if someone have the same problem, could help you.
Nancy.

How can I increase the maximum file name size of attachments in Prestashop 1.7

On Prestashop 1.7, how can I increase the maximum file name size of attachments?
While naming attachment files in the Back Office, I encounter the following error message.
How can I go around this problem in Prestashop 1.7? I looked up online and found some solutions for Prestashop 1.5 or 1.6, but not for 1.7.
Here are some links that I followed:
https://www.prestashop.com/forums/topic/63332-bug-the-field-mime-is-too-long-32-chars-max/?tab=comments#comment-1189602
https://www.prestashop.com/forums/topic/81129-solvedhow-to-change-the-length-of-the-file-name-of-the-attachement/?tab=comments#comment-1197114
Following the above links, I have tried:
In the DB, changed the 'name' column's type in the 'ps_attachment_lang' table to 'varchar(128)'.
In Attachment.php (/classes/Attachment.php), made sure the size is 128.
'name' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128],
In AdminProductsController.php (/controllers/admin/AdminProductsController.php), changed a part of function ajaxProcessAddAttachment(), from
if (!Validate::isGenericName($name)) {
$_FILES['attachment_file']['error'][] = $this->trans('Invalid name for %s language', [$language['name']], 'Admin.Notifications.Error');
} elseif (Tools::strlen($name) > 32) {
$_FILES['attachment_file']['error'][] = $this->trans('The name for %1s language is too long (%2d chars max).', [$language['name'], 32], 'Admin.Notifications.Error');
}
to
if (!Validate::isGenericName($name)) {
$_FILES['attachment_file']['error'][] = $this->trans('Invalid name for %s language', [$language['name']], 'Admin.Notifications.Error');
} elseif (Tools::strlen($name) > 64) {
$_FILES['attachment_file']['error'][] = $this->trans('The name for %1s language is too long (%2d chars max).', [$language['name'], 64], 'Admin.Notifications.Error');
}
But unfortunately, none of them worked.
Thanks in advance.
This is my own question but I found one solution.
In the AttachmentConstraint.php (in /src/Core/Domain/Attachment/Configuration/AttachmentConstraint.php), find the line
const MAX_NAME_LENGTH = 32;
and change it to whatever number that is lower than your database table can hold:
//const MAX_NAME_LENGTH = 32;
const MAX_NAME_LENGTH = 128; // this number needs to be lower than `name` column in `ps_attachment_lang` table
This should do the trick, but this solution requires changes in the core file. If there's anyone who knows a way we can achieve this without modifying the core files, please share that.

PHPWord generated docx watermark image with 0 margin is shifted with some space from left and top edge of document

I generate a docx document with PHPWord and want to make an image to be as a background. Watermark is totally the point for it.
Everything works fine generating document like sections, paragraphs, font styles and sizes, line heights, etc.
But I stucked with this part: my image for background with margins 0 is always shifted with some space from the document's edge.
I go with this code:
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$header = $section->addHeader();
$header->addWatermark($path . '/images/test.jpg',
array(
'marginTop' => 0,
'marginLeft'=> 0,
)
);
$section->addText('Is Richard Deckard a replicant?');
$timestamp = date('Hi-ymd');
$filename = 'DOC_' . $timestamp;
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save($path . '/docs/' . $filename . '.docx');
The result is:
PHPWord watermark image for background
So as you see margins are not 0 but the image is some distance from the left and top edge of the page.
I was able positioning background image to the top-left edge this way
$header = $section->addHeader();
$header->addWatermark('images/test.png',
array(
'width' => 596,
'marginTop' => -36,
'marginLeft' => -50,
'posHorizontal' => 'absolute',
'posVertical' => 'absolute',
));
I think the point is the absolute parameter.
I needed to make negative values on margins, because my body section had inner margins.
I was having the same problem and fortunately I found this question and the answer from #vorvor. Thank you for the answer #vorvor.
I did the same thing in a Laravel 5.6 project and just wanted to share my code with you.
$header = $section->addHeader();
$bg_image = Storage::url('itinerary-assets/Untitled-1_compressed.jpg');
$header->addWatermark($bg_image, [
'marginTop' => -36,
'marginLeft' => -50,
'posHorizontal' => 'absolute',
'posVertical' => 'absolute'
]);

PayPal Api Patch on Itemlist doesn't work

I want to add an item to my transaction.
$json = '
[
{
"name": "Voucher",
"description":"Voucher",
"price":"50.00",
"currency":"EUR",
"quantity":"1"
}
]';
$patchAddItem = new \PayPal\Api\Patch();
$patchAddItem->setOp('add')
->setPath('/transactions/0/item_list/items')
->setValue(json_decode($json));
$patchReplace = new \PayPal\Api\Patch();
$patchReplace->setOp('replace')
->setPath('/transactions/0/amount')
->setValue(json_decode('{
"total": "159.00",
"currency": "EUR",
}'));
$patchRequest = new \PayPal\Api\PatchRequest();
$patchRequest->setPatches(array($patchAddItem, $patchReplace));
try {
$this->payment->update($patchRequest, $this->apiContext);
} catch (PayPal\Exception\PayPalConnectionExceptio $ex) {
echo '<pre>';print_r(json_decode($ex->getData()));exit;
}
But I get following Error
Eception: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAY... in PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php on line 154
PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php on line 73: PayPal\Core\PayPalHttpConnection->execute("[{"op":"add","path":"/transactions/0/item_list/ite"... )
PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php on line 102: PayPal\Transport\PayPalRestCall->execute(array[1],"/v1/payments/payment/PAY-1S151200BX2478240LEAG3CI","PATCH","[{"op":"add","path":"/transactions/0/item_list/ite"... ,null)
PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php on line 615: PayPal\Common\PayPalResourceModel::executeCall("/v1/payments/payment/PAY-1S151200BX2478240LEAG3CI","PATCH","[{"op":"add","path":"/transactions/0/item_list/ite"... ,null,object,null)
At this moment I didn't execute the payment object. Do I have to edit the total attribut from amount too? Well, I tried this too, with same issue...
Even if you are sending only one item to PayPal you still have to set them as an item list with setItemList().
That array should be visible if you json_decode in your payment array:
[item_list] => Array
(
[items] => Array
(
[0] => Array
(
[name] => Ground Coffee 40 oz
[sku] => 123123
[price] => 52.80
[currency] => USD
[quantity] => 1
)
)
I had not run a patch for an item yet. I attempted to send an 'add' similar to your code and tried changing the path to '/transactions/0/item_list/items/1' using the next number in the items array. But could not get an add to work.
The only way I could modify the item_list was to do a complete 'replace' of the item_list, so in a running shopping cart would have to include all the items being purchased, not just the new item.
To do this I prefer to use the functions from the PayPal sdk vs building the json arrays. Their examples of how to create and execute a payment are fairly good and use the SDK functions. http://paypal.github.io/PayPal-PHP-SDK/sample/
However the example on updating a payments builds the json arrays outright.
Below is a testing function to modify the item_list using the Paypay PHP SDK Class Functions. I hard coded the Subtotal and Total to match the values coming form the shopping cart plus the increase from the new item. The item_list is also hard coded using PP's example data. Otherwise item's arrays would be built off of a user's shopping cart items. The type is set to 'replace'.
So, yes. Subtotals and Totals need to be updated to match as well, else the PP call will fail.
function updatePayPalPayment ($type, $createdPayment, $total, $subtotal, $shipping, $currency) {
$subtotal = '54.80';
$total = '71.73';
$details = new Details();
$details->setShipping($shipping)
->setSubtotal($subtotal);
$amount = new Amount();
$amount->setCurrency($currency)
->setTotal($total)
->setDetails($details);
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setSku("123123") // Similar to `item_number` in Classic API
->setPrice(52.80);
$item2 = new Item();
$item2->setName('Granola bars')
->setCurrency('USD')
->setQuantity(1)
->setSku("321321") // Similar to `item_number` in Classic API
->setPrice(2.0);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$patchItem = new Patch();
$patchItem->setOp($type)
->setPath('/transactions/0/item_list')
->setValue($itemList);
$patchAmount = new Patch();
$patchAmount->setOp($type)
->setPath('/transactions/0/amount')
->setValue($amount);
$patchRequest = new PatchRequest();
$patchRequest->setPatches(array($patchAmount, $patchItem));
$update = $createdPayment->update($patchRequest, getApiContext());
return $update;
}
I also have found it very helpful to set the apiContext for logging to DEBUG and output to a file in development for much better error messages.
'log.LogEnabled' => true,
'log.FileName' => '_PayPal.log',
'log.LogLevel' => 'DEBUG',
Hope that helps.

How to use Yii CArrayDataProvider

I am new to php and Yii and need some help regarding showing array in the webpage.
In the controller I open my e-mail inbox and iterate through the e-mails in inbox and build array with each e-mail address as key having values
if (array_key_exists($fromemail,$senders))
{ $senders[$fromemail]['rcount']++; }
else {
$senders[$fromemail]['e-mail'] = $fromemail;
$senders[$fromemail]['Name'] = $fromname;
$senders[$fromemail]['rcount'] = 1;
}
$model->top_senders = $senders;
$this->render('Step2',array('model'=>$model,));
Then in the view file of Step2 I want to show the data in CGridview
if (isset($model->top_senders))
{
$gridDataProvider = new CArrayDataProvider($model->top_senders);
$gridDataProvider->setData($model->top_senders);
$gridColumns = array(
array('name'=>'e-mail', 'header'=>'E-mail','value' =>'$data->e-mail'),
array('name'=>'rcount', 'header'=>'# of mails','value'=>'$data->rcount'),);
$this->widget('bootstrap.widgets.TbGridView',array('dataProvider' => $gridDataProvider,'template' => "{items}",'columns'=>$gridColumns));
}
But I will get error during rendering of the table: PHP notice Undefined offset: 0
/**
125 * Renders a data cell.
126 * #param integer $row the row number (zero-based)
127 */
128 public function renderDataCell($row)
129 {
130 $data=$this->grid->dataProvider->data[$row];
What I am doing wrong? Can anyone help me?
You should't add data to provider as follows:
$gridDataProvider->setData($model->top_senders);
It added during initialization. You must be sure that the array has a key id, otherwise you need to specify it manually (it must be unique) as follows:
$gridDataProvider = new CArrayDataProvider($model->top_senders, array(
'id'=>'Name',
));
You will also need to make sure that the array $model->top_senders has the following structure:
array(
'0'=>array(...user data here),
'1'=>array(...user data here),
...
);
If you var_dump($gridDataProvider->data) you'd notice there's no value for the 0th index in the array. This happens when you run some filter function on the array. Assuming there are 5 values in the filtered array, the filtered array would look something like this when var_dump'd.
array(5) {
[1] => Object (Mailer) {…},
[2] => Object (Mailer) {…},
[4] => Object (Mailer) {…},
[8] => Object (Mailer) {…},
[9] => Object (Mailer) {…},
}
A filter operation on an array can leave the array looking like the above.
When the CGridView is trying to feed the view with data, it does it sequentially—this, I find, is a shortcoming in Yii and should be raised as an issue.
In order to fix this, use PHP's array_values() like so…
$properly_indexed_array = array_values($filtered_array);
This will copy the values of the filtered array into a new array. This is not the optimal solution in terms of memory. So far, I do not see any means in PHP other than this though.
You may then go ahead and set this as the data for your data provider like so…
$gridDataProvider->setData($properly_indexed_array);