I'm migrating a bundle, that add a link button on the product page, from akeneo 2.3 to akeneo 3.2. With 2.3 we have a parameter defined on parameters.yml as
#CUSTOM
magento_base_url: http://mymagento.com/
then in the form_extensions
extensions:
pim-product-edit-form-magento-link-frontend:
module: pim/product-edit-form/magento-link
parent: pim-product-edit-form
targetZone: buttons
position: 90
magentoBaseUrl: "%magento_base_url%" <-- MY CUSTOM ATTR
type: frontend
then in js i will have
define(
[
'underscore',
'oro/translator',
'pim/form',
'pim/template/product/magento-link'
],
function (_,
__,
BaseForm,
template) {
return BaseForm.extend({
template: _.template(template),
render: function () {
let linkPath,
linkLabel,
sku = this.getFormModel().get('identifier'),
baseUrl = this.options.magentoBaseUrl; <-- THIS
where baseUrl contains http://mymagento.com/
After upgrading to 3.2 the value on baseUrl is exactly %magento_base_url%
What i should do to pass this parameter to the js stack?
Seems that from version 3.2 akeneo use a node engine to parse form_extensions yaml and you can't access anymore these parameteres. As workaround i wrote a controller and retrieve the value via ajax
Related
I just started playing around with strapi using it for my next project with nextjs and i got stuck a little bit on the slug part.
I have installed the slugify plugin in the strapi admin panel, restarted the server and in the roles(permissions) section i enabled it for both authenticated and public roles.After this i created a collection type name Blog. I added some fields to it title, content, cover, slug(short text).
After this i created some blog posts and listed them out on the page. The problem began when i tried to access the blog post using the slug:
`${process.env.NEXT_PUBLIC_STRAPI_URL}/slugify/slugs/blog/${slug}?populate=*`,
The url is ok as the slug part is populated and is the value that i have given the slug field when created the blog post. The error that i get is the following:
blog model name not found, all models must be defined in the settings and are case sensitive.
The problem is that the slugify plugin is trying to match the model name to the existing ones and its not finding it so throws this error.
I started to dig a little bit deeper and began to console log in the slugify plugin inside strapi node_module:
module.exports = ({ strapi }) => ({
async findSlug(ctx) {
const { models } = getPluginService(strapi, 'settingsService').get();
const { modelName, slug } = ctx.request.params;
const { auth } = ctx.state;
console.log(getPluginService(strapi, 'settingsService').get());
isValidFindSlugParams({
modelName,
slug,
models,
});
As you can see it should container a models param aswell that should contain all the current models created in strapi. However the model paramateres comes back as an empty object, its like the plugin does not see the created collections.
The collections were created after the instalation of the slugify plugin.
I am developing on localhost using sqlite with strapi v4.
Any ideas why is this happening? Anyone else encountered this error?
Thanks,
Trix
Firstly, you have to install Slugify plugin.
After that you have to do some config steps.
To do all of that:
As you mentioned, you found Slugify folder in node_modules so you can skip first step:
npm install strapi-plugin-slugify
in the ./config/ folder create a file named plugins.js
./config/plugins.js
Paste this code there it will let you see the endpoint path in the right side of the screen:
module.exports = ({ env }) => ({
// ...
slugify: {
enabled: true,
config: {
contentTypes: {
blog: { //write what your collection type's name is this case we should use "blog"
field: "slug",
references: "title",
},
},
},
},
// ...
});
The endpoint example
fetcher(`${API}/slugify/slugs/blog/${slug}`)
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `#gatsbyjs`,
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
{
resolve: "gatsby-source-graphql",
options: {
// Arbitrary name for the remote schema Query type
typeName: "DRUPAL",
// Field under which the remote schema will be accessible. You'll use this in your Gatsby query
fieldName: "drupal",
// Url to query from
url: "https://intl-pgs-rsm-growth-platform.pantheonsite.io/graphql",
},
},
],
}
Here's my gatsby-config.js file
When I run gatsby clean && gatsby develop or just gatsby build i get
success createSchemaCustomization - 0.005s
ERROR #11321 PLUGIN
"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:
Unexpected token < in JSON at position 0
ServerParseError: Unexpected token < in JSON at position 0
- JSON.parse
- index.js:35
[test-gatsby]/[apollo-link-http-common]/lib/index.js:35:25
- next_tick.js:68 process._tickCallback
internal/process/next_tick.js:68:7
not finished source and transform nodes - 0.506s
My Drupal 8 site is new with the graphql module installed. And the gatsby site is brand new too.
I started getting this issue on Monday after working fine for a while. There were no code changes to my gatsby but all of a sudden I'm no longer able to get drupal data.
There seems to be few examples of using the "gatsby-source-graphql" plugin so if anyone can help please do
In my case, it was a permissions issue in Drupal. I solved it by going to admin → people → permissions and setting all permissions related to GraphQL for the anonymous user.
The Drupal Graph QL Module requires authentication using tokens. You can use Simple Oauth or JWT. I used Simple Oauth and resolved my issue using the following steps:
Install the Simple Oauth module using composer so it installs it's dependancies $ composer require drupal/simple_oauth, then enable the module.
Create a user role for your third party app and assign content viewing permissions for that role
In admin/config/people/simple_oauth add a token expiration time, generate keys using the button provided (make sure they are generated outside of the drupal web root) and add the path to the public and private key files.
In admin/config/services/consumer add a new consumer (or use the default consumer)
Add a secret password in the Secret field and select the new role you created under Scopes, then save the config page.
Make a post request to your site https://intl-pgs-rsm-growth-platform.pantheonsite.io/oauth/token using curl or postman to generate a token using the following body fields:
grant_type: password
client_id: The client id generated `admin/config/services/consumer`
client_secret: The secret you entered in step 4
username: A user in your drupal site that has the role you created
password: The password assigned to that account
The post request should return the access token if successful. Add your token to your app's .env.development file and update your gatsby-config.js file with the Authorization header: (More info about setting up environment variables in your gatsby app can be found here)
{
resolve: "gatsby-source-graphql",
options: {
typeName: "DRUPAL",
fieldName: "drupal",
url: "https://intl-pgs-rsm-growth-platform.pantheonsite.io/graphql",
headers: {
"Authorization": `Bearer ${process.env.GATSBY_API_TOKEN}`
},
},
},
Video Tutorials of the Simple Oauth set up steps can be found here
More information on this set up process can be found here
I have generated a Grid with CRUD actions for my Labellisation entity on Sylius.
The grid is displayed well, but I would like to get associated elements too (the defaultAdresse of the -> customer of the -> current labellisation), so I need to use a custom repository method.
I tried to do this with this conf :
labellisation_grid:
resource: |
alias: grid.label
criteria:
valide: true
except: ['create', 'delete', 'update']
grid: public_labels
templates: LabelBundle:public/Crud
type: sylius.resource
defaults:
_sylius:
repository:
method: findAllValides
(adding all the defaults block), but I have an error because the method findAllValides is not defined. I do have a findAllValides method in my LabellisationRepository.
Debugging the ResourcesResolver, I saw in the getResource that the $repository passed to this function has a customRepositoryClassName = LabelBundle\Repository\LabellisationRepository (this path is the good one to my LabellisationRepository).
Is there something wrong with my code ?
Is there a way to turn off all of the Nelmio Swagger UI docs? In production I want the outside world to see nothing at the following URLs, but in dev they should display useful docs & sandbox as normal:
http://ourserver.com/api/doc
http://ourserver.com/api-docs
http://ourserver.com/api-docs/*
Seems like there should be an easy switch for this in the Nelmio config, but I haven't found it. My company is using the Nelmio API Doc bundle in Symfony to develop APIs for a non-public API. The API server is exposed to the public, but we're not interested in publishing its usage to the world.
#gp_sflover's comment got me on the right track, but there's more to it than just disabling NelmioApiDocBundle on prod in AppKernel.php. Configs & routes that refer to Nelmio will generate errors until you move them into dev-specific files. The following change in app/AppKernel.php was the first step:
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
...
// new Nelmio\ApiDocBundle\NelmioApiDocBundle(), // <-- REMOVED FROM HERE
new Nelmio\CorsBundle\NelmioCorsBundle(),
new AppBundle\AppBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Nelmio\ApiDocBundle\NelmioApiDocBundle(); // <-- ADDED HERE
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
...
To eliminate the config errors, I had to move the following stuff out of app/config/config.yml and into config_dev.yml:
# nelmio Configuration
nelmio_api_doc:
sandbox:
enabled: true
name: 'DLAP API Bridge'
swagger:
...
cache:
enabled: false
Likewise, the following stuff came out of app/config/routing.yml and moved to routing_dev.yml:
NelmioApiDocBundle:
resource: "#NelmioApiDocBundle/Resources/config/routing.yml"
prefix: /api/doc
nelmio_api_swagger:
resource: "#NelmioApiDocBundle/Resources/config/swagger_routing.yml"
resource: null
prefix: /api-docs
Now with symfony4 and flex you can install the bundle normally
composer require nelmio/api-doc-bundle
(So it won't be set as a require-dev depandency in your composer.json)
Now you change the setting in the project/config/bundles.php to:
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['dev' => true]
So you don't get errors (eg from annotations), but it wont be loaded from Kernel.php
For disabling the Nelmio api-doc-bundle on specific environment, after some investigation, I ended up doing the following:
only enable the bundle on your target environment, i.e. on project/config/bundles.php have:
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['dev' => true]
put the config annotation on env specific (put nelmio_api_doc.yaml inside ./config/packages/dev/)
put the route file nelmio_api_doc.yaml inside ./config/routes/dev (instead of being in the ./config/routes), otherwise, if you call the route for another environment which doens't have the bundle loaded, instead of 404, you will see 500)
not loading the bundle in config/bundles.php throws an exception in Symfony 4.3 with NelmioApiDocBundle Version 3:
There is no extension able to load the configuration for "nelmio_api_doc"
I ended up disabling the route for the api docs with a redirect in the environment, which needed to be disabled (prod):
#config/routes/prod/nelmio_api_doc.yaml
app.swagger:
path: /api/doc.json
methods: GET
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /
permanent: true
app.swagger_ui:
path: /api/doc
methods: GET
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /
permanent: true
After updating symfony2 with the dependencies to 2.8 I get the following error message when trying to override the sonata user bundle registration form:
The field type "Sonata\UserBundle\Form\Type\RegistrationFormType" is not registered with the service container.
If I switch back to Symfony 2.7 everything works again.
My services.yml:
sonata.user.registration.form.type:
class: My\Bundle\Form\Type\RegistrationFormType
arguments: [ "%fos_user.model.user.class%" , "#service_container"]
tags:
- { name: form.type, alias: sonata_user_registration }
In my controller the following line triggers the error:
$form = $this->container->get( 'sonata.user.registration.form' );
Unfortunately I couldn't find any resources on this subject (i.e. if there are any changes in overriding the registration form since the latest version)
Ok, this isn't a bug, but a new feature. You have to use the build() and boot() methods in your bundle to register your FormType via FormHelper::registerFormTypeMapping.