Magento 2 - Edit Invoice PDF in a custom theme - magento2

I want to edit the printable PDF invoice in Magento 2. To do this, I need to edit:
vendor/magento/module-sales/Model/Order/Pdf/AbstractPdf.php
But, what is the path I need so it does not get overridden during upgrade. I know the path should be something like this (but i cant figure it out):
/app/design/frontend/Vendor/Theme/Magento_Sales/ ? / ? / AbstractPdf.php
With templates, I know the path is /template/...but this is a Model - so Im not sure I know how that works.

The path is the same as is in module-sales, so: /app/design/frontend/Vendor/Theme/Magento_Sales/Model/Order/Pdf/AbstractPdf.php
is where to put it.

Related

Filename not shown in Symfony 5.2 in form

I am just learning Symfony and maybe I am doing something wrong.
I created a simple form with the possibilty to upload a file. After choosing the file the filename doesn't show up in the form.
Screen 1 - Choose picture
Screen 2 - Filename isn't shown
The picturename is correctly saved to the database, so it must be there :)
I used ->add('picture', FileType::class, ['required' => false])
Can someone push me in the right direction. I am trying to figure this out for the last 2 hours.
There is a "bug" with that type of field in Symfony when using the Bootstrap form theme.
If you are using Symfony's Boostrap form theme
# config/packages/twig.yaml
twig:
default_path: '%kernel.project_dir%/templates'
form_themes:
- 'bootstrap_4_horizontal_layout.html.twig'
I would recommend adding some Javascript to fix this issue.
$('.custom-file-input').on('change', function(event) {
let inputFile = event.currentTarget;
$(inputFile).parent().find('.custom-file-label').html(inputFile.files[0].name);
});
Note that I'm using ES6 syntax here, for better compatibility with old browsers, you might want to use ES5 if you are not using a transpiler. Also, I using the custom-file-label class since I'm using Symfony's Bootstrap 4 form theme, you might want to adjust if you are using another theme.
..files[0].name is used since your FileType could accept multiple files.

Is it possible to use mkdocs without links related to filename

Here is the issue:
Mkdocs use filename to build links.
However, users who update the doc often change the name of the files, as they use ordered titles (1 1 Introduction.md, 1 2 Main Content.md, ...)
Of course, they put links to other pages in their doc like this : (Introduction)[./1%201%20Introduction/#Paragraph2]
When they change the filename, the link ends up broken. Is there any way to link to another page#anchor without referring to filename and avoid broken link when changing file name? (Plugin, option in mkdocs, something I missed, ...)
Thanks in advance
I found the answer, and it was really obvious.
We don't use the nav property of the yml file to build the tree automatically and we could define it to avoid being dependent on file name for ordering.
Therefore, the filename could still not be modified but we can define the ordering in the nav property and rename the page title easily.
Obvious solution, but we missed it.

Prestashop 1.7 - filtering not working, showing empty results

I have got a problem on my store (still under development) - http://condesign.pl/officina . It's all about filtering products, for example here: http://condesign.pl/officina/pl/521-akcesoria-ze-skory . All the attributes on the left are being displayed correctly, with numbers of products in brackets, but when You click on any filter (like size or color), the list of results is empty.
Help please!
Try yo do the exact same thing with the default theme of Prestahsop. Because this looks like a theme issue.
This is very large bug in ps_facetedsearch module... You can't do anything with this. You must wait for fix. https://github.com/PrestaShop/PrestaShop/issues/9684 here is list of bugs in module.
It was my mistake - this module uses table ps_stock_available. I was migrating data from previous store to this one (only in phpmyadmin, not panel, because of very different structures), and I didn't know about this table. So it was about my missing data.

Changing Templavoila field names

In the process of cleaning up some Templavoila Plus FCE, I created a new FCE template that will replace several others. To do so, I created some new field names to replace the old ones. (I noticed you can't change the name of a field after creating it).
For example, I had field_title_A for FCE A, field_title_B for FCE B, etc… Now I just have field_title in my new FCE template.
The problem is that if I change the FCE / Template Object for an existing content, the title field is now empty. It doesn't understand that field_title_A is now field_title.
I seriously doubt that there is a solution, but I still hope there is one.
Is there something I can do to tell TV to move the content of field_title_A to field_title or to tell it field_title_A is now field_title? Is there another way to achieve that?
If I'm not using some terms properly, please, feel free to edit.
no, there is no such support present yet. You could open a feature request for that, but I don't think I could work out a sollution in the next 2 years.

Typoscript filelink - Wrap URL within link

First, here is the Typoscript :
20 = TEXT
20 {
value {
field = field_title
wrap = |.txt
}
filelink {
stdWrap.wrap = <li>|</li>
path = fileadmin/txt-files/
}
}
The result I get is :
<li>
<a href="/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
And what I need is :
<li>
<a href="/fileadmin/force_download_script.php?filepath=/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
I need to make the link downloadable, rather than opening the file in the browser. For that I have a force_download_script.php, but when I do that :
wrap = fileadmin/force_download_script.php?filepath=|txt
instead of the current wrap, filelink doesn't find the file anymore.
I have tried using ATagBeforeWrap.wrap but it doesn't look like it's made for that purpose. I also tried typolinkConfiguration.wrap without any success.
Any idea of how to achieve that ? Using a COA maybe ?
Thank you !
I would not do this with a script, but with server configuration. If you use Apache and have .htaccess enabled, you can add the configuration to a .htaccess file in the directory where the files are located. See https://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/
Alternatively you can also use the HTML5 download attribute. This is not supported by Internet Explorer however (it is supported by Edge though).
The issue can get quite a bit complicated, but step by step:
your code above might be wrong if it's not just a copy & paste fault:
wrap = fileadmin/force_download_script.php?filepath=|.txt
The dot before txt was missing.
Nevertheless it is still interesting if the php-script is triggered.
It's possible that the script is not triggered due to some settings in typo3conf/LocalConfiguration.php respectively some settings in the install-tool.
Depending on the TYPO3-Version it's also possible that the script is not triggered at all because all scripts are being required now in an extension. That means you might need to create an extension for that script.
Also simple wrapping of the result with the script-path might not be enough, but you have to call it explicitly by TypoScript perhaps by including the script as user-function or lib.
The admin-panel might be useful to debug some things about your script but if not you've to include some debug-output first in your own code, if that's not enough in the core (temporary).
So you've to find out if your script is triggered and if not, the reason for it.
Are you sure .filelink is what you are looking for?
.filelink is for a set of files. For all files in the folder given by .path a link will be generated. see manual
From your description you want a text wrapped with a link to one single file. That would be more a problem for .typolink where you specify the link in .parameter.
if you really want a link list of multiple files, each wrapped with your script you need to modify .typolinkConfiguration.parameter which will be used internaly by .filelink.
Anyway it might be possible to do a wrap which then would be:
.typolinkConfiguration.parameter.wrap = /fileadmin/force_download_script.php?|
Maybe it is easier to build your list with .stdWrap.filelist, where you can use the filenames in any way to wrap your own href parameter for an A-tag.
To use the TYPO3 core solution with file links you can use this guide:
Create a file storage where you want your "secured" files in TYPO3 backend
Do not set the checkbox "Is public?" in the storage record
The links will be rendered with eID and file parameters
You can look into the FileDumpController handling these links: https://github.com/TYPO3/TYPO3.CMS/blob/2348992f8e3045610636666af096911436fa1c89/typo3/sysext/core/Classes/Controller/FileDumpController.php
You can use the included hook to extend this controller with your logic.
Unfortunately I can't find any official documentation for this feature, but will post it when I find something or wrote it myself. ;)
Maybe this can help you, too: https://extensions.typo3.org/extension/fal_securedownload/
Here is the official part, but it's not much: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Fal/Administration/Storages.html?highlight=filedumpcontroller