Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
Forum Replies Created
-
AuthorReplies
-
October 16, 2019 at 3:24 pm in reply to: Symfony Form constraints not working for my Custom Form type #40715October 16, 2019 at 11:32 am in reply to: Symfony Form constraints not working for my Custom Form type #40711
But that is already defined in the Parent form type
vendor/oro/commerce/src/Oro/Bundle/ProductBundle/Form/Type/FrontendLineItemType.php classPHP1234567891011/*** {@inheritdoc}*/public function configureOptions(OptionsResolver $resolver){$resolver->setDefaults(['validation_groups' => ['add_product'],]);}Also the other children Form types like vendor/oro/commerce/src/Oro/Bundle/ProductBundle/Form/Type/QuantityType.php does not have the validation group defined separately.
Also, more info, my validation works for the Backend which is loaded from the validation.yml. It just does not work on FrontEnd. The input element does not show a ‘data-validation’ attribute for my custom form just like it does for the QuantityType form.
What am I missing here?
Thanks in advance.
Just to clarify, the First screenshot is how validation.yml is set in Oro’s ProductBundle.
The Trial screenshots are how I tried to overwrite from my own custom bundle’s validation.yml.
-
This reply was modified 2 years, 8 months ago by
Shahriar.
September 12, 2019 at 9:34 am in reply to: How does 'Direct URLs' section of Admin panel works? #40424Thanks. After running message consumer the product prefixes are working. But they are only working on accessing products from Master Catalog.
I also have a web catalog on, whenever I am accessing those same products from Web Catalog, the prefixes dont show up. Do you have any idea on why that might be?
Thanks. :)
August 1, 2019 at 10:20 pm in reply to: How to replace or extend Configuration.php of OroProductBundle? #40097Okay, I fixed it. Thanks for the suggestion!
You are right, I dont need to extend ProductBundle’s Configuration instead I can just have my own bundle’s Configuration.It looks like, I was adding Configuration for my own bundle but was not really calling it correct ALIAS.
I corrected this function in my NewBrandsProvider class
PHP12345protected function getSegmentId(){return $this->getConfigManager()->get(sprintf('%s.%s', 'acme_brand', Configuration::NEW_BRANDS_SEGMENT_ID));}Also corrected the service name in system_configuration_services.yml
YAML123456789101112parameters:acme_brand.segment.new_brands.name: 'New Brands'services:acme_brand.provider.default_value.new_brands:parent: oro_config.provider.value.entity_idarguments:- '@oro_entity.doctrine_helper'- '%oro_segment.segment.entity.class%'-'entity': '%oro_product.entity.brand.class%''name': '%acme_brand.segment.new_brands.name%'My getSegmentId() is now returning the id. This is resolved now. :)
-
This reply was modified 2 years, 11 months ago by
Shahriar.
August 1, 2019 at 6:36 am in reply to: How to replace or extend Configuration.php of OroProductBundle? #40091Then actual error looks like this:
new_brands_segment_id is not found in oro_product.settings
July 31, 2019 at 8:27 pm in reply to: How to replace or extend Configuration.php of OroProductBundle? #40078Hello Andrey,
Thanks for your reply. Let me give you more info on what am I trying to achieve here.I created a custom segment called New Brands, which I want to show on my Home page similar to Featured Product or New Arrivals. My New Brand Segment uses a condition to show brands that are created between certain dates. Right now, I have created a NewBrandsProvider, where I used a segmentManager to fetch New Brands segment by id. This works when I pass in segment id with hard code. But I am trying to get the id dynamically as well. This is how my NewBrandsProvider looks:
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657<?phpnamespace Acme\BrandBundle\Layout\DataProvider;use Oro\Bundle\ConfigBundle\Config\ConfigManager;use Acme\BrandBundle\DependencyInjection\Configuration;use Oro\Bundle\SegmentBundle\Entity\Manager\SegmentManager;class NewBrandsProvider{private $segmentManager;private $configManager;public function __construct(SegmentManager $segmentManager,ConfigManager $configManager) {$this->segmentManager = $segmentManager;$this->configManager = $configManager;}public function getBrands(){if(!is_null($this->getSegmentId())){$segment = $this->segmentManager->findById($this->getSegmentId());$qb = $this->segmentManager->getEntityQueryBuilder($segment);$result = $qb->getQuery()->getResult();return $result;}else {$segment = $this->segmentManager->findById(50);$qb = $this->segmentManager->getEntityQueryBuilder($segment);$result = $qb->getQuery()->getResult();return $result;}}protected function getSegmentId(){dump($this->getConfigManager()->get(sprintf('%s.%s', 'oro_product', Configuration::NEW_BRANDS_SEGMENT_ID)));return $this->getConfigManager()->get(sprintf('%s.%s', 'oro_product', Configuration::NEW_BRANDS_SEGMENT_ID));}protected function getConfigManager(){return $this->configManager;}}I also added a system_configuration_services.yml with below:
YAML123456789101112parameters:oro_product.segment.new_brands.name: 'New Brands'services:oro_product.provider.default_value.new_brands:parent: oro_config.provider.value.entity_idarguments:- '@oro_entity.doctrine_helper'- '%oro_segment.segment.entity.class%'-'entity': '%oro_product.entity.brand.class%''name': '%oro_product.segment.new_brands.name%'Now if I add the below NEW_BRANDS_SEGMENT_ID node inside OroProductBundle Configuration.php, my NewBrandsProvider can dynamically get the segment id with getSegmentId() function. Which tells me I can manually add a configuration node for my custom Segment ID which I can make query on.
PHP1234567891011121314151617181920/*** {@inheritDoc}*/public function getConfigTreeBuilder(){$treeBuilder = new TreeBuilder();$rootNode = $treeBuilder->root(static::ROOT_NODE);SettingsBuilder::append($rootNode,[static::NEW_BRANDS_SEGMENT_ID => ['value' => '@oro_product.provider.default_value.new_brands'],]);return $treeBuilder;}But obviously, I don’t want to edit core codes and want the same facility by using same logic in my custom bundle.
Which is why I wanted to make my own Configuration.php but it was returning “null” for getSegmentId().
Alternate Ways I tried: I thought I need to extend ProductBundle’s Configuration.php as Brand entity is defined inside ProductBundle. So, after my custom bundle’s(BrandBundle) Configuration.php was not working, I also added the below Extension class to extend ProductBundle’s configs from my Custom Bundle.
PHP12345678910111213141516171819202122232425262728293031323334353637383940414243444546<?phpnamespace Acme\BrandBundle\DependencyInjection;use Symfony\Component\Config\FileLocator;use Symfony\Component\DependencyInjection\ContainerBuilder;use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;use Symfony\Component\DependencyInjection\Loader;use Symfony\Component\HttpKernel\DependencyInjection\Extension;class AcmeBrandExtension extends Extension implements PrependExtensionInterface{const ALIAS = 'oro_product';public function load(array $configs, ContainerBuilder $container){$configuration = new Configuration();$config = $this->processConfiguration($configuration, $configs);$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));$loader->load('services.yml');$loader->load('system_configuration_services.yml');$container->prependExtensionConfig($this->getAlias(), $config);}public function prepend(ContainerBuilder $container){$configuration = new Configuration();$configs = $container->getExtensionConfig('acme_brand');$config = $this->processConfiguration($configuration, $configs);$container->prependExtensionConfig('oro_product', $config);if (isset($config['entity_manager_name'])) {$config = ['entity_manager_name' => $config['entity_manager_name']];$container->prependExtensionConfig('oro_product', $config);}}}But after adding this extension, I was getting error on cache:clear saying NEW_BRANDS_SEGMENT_ID was not found.
I am sorry for this long post but will appreciate any advice to the right direction. :)
-
This reply was modified 2 years, 8 months ago by
-
AuthorReplies