{"id":300398,"date":"2021-08-08T14:40:47","date_gmt":"2021-08-08T14:40:47","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=300398"},"modified":"2021-08-08T14:42:25","modified_gmt":"2021-08-08T14:42:25","slug":"adjust-price-at-product-and-category-page","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/","title":{"rendered":"Adjust Price At Product And Category Page."},"content":{"rendered":"\n<p>One can adjust the price of saleable entity at product and category page.<\/p>\n\n\n\n<p>For adjustments, create file etc\/di.xml in your module:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;type name=&quot;Magento\\Framework\\Pricing\\Adjustment\\Collection&quot;&gt;\n  &lt;arguments&gt;\n    &lt;argument name=&quot;adjustments&quot; xsi:type=&quot;array&quot;&gt;\n      &lt;item name=&quot;price_adjustment&quot; xsi:type=&quot;const&quot;&gt;VENDOR\\MODULE\\Pricing\\Adjustment::ADJUSTMENT_CODE&lt;\/item&gt;\n    &lt;\/argument&gt;\n  &lt;\/arguments&gt;\n&lt;\/type&gt;\n&lt;type name=&quot;Magento\\Framework\\Pricing\\Adjustment\\Pool&quot;&gt;\n  &lt;arguments&gt;\n     &lt;argument name=&quot;adjustments&quot; xsi:type=&quot;array&quot;&gt;\n        &lt;item name=&quot;price_adjustment&quot; xsi:type=&quot;array&quot;&gt;\n           &lt;item name=&quot;className&quot; xsi:type=&quot;string&quot;&gt;VENDOR\\MODULE\\Pricing\\Adjustment&lt;\/item&gt;\n           &lt;item name=&quot;sortOrder&quot; xsi:type=&quot;string&quot;&gt;10&lt;\/item&gt;\n        &lt;\/item&gt;\n     &lt;\/argument&gt;\n  &lt;\/arguments&gt;\n&lt;\/type&gt;<\/pre>\n\n\n\n<p>Now create the Adjustment.php file :  VENDOR\\MODULE\\Pricing\\Adjustment.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">namespace VENDOR\\MODULE\\Pricing;\n\nuse Magento\\Framework\\Pricing\\Adjustment\\AdjustmentInterface;\nuse Magento\\Framework\\Pricing\\SaleableInterface;\n\nclass Adjustment implements AdjustmentInterface\n{\n\n    const ADJUSTMENT_CODE = &#039;price_adjustment&#039;;\n    const ADJUSTMENT_PRICE = 1.79;\n\n    \/**\n     * Get adjustment code\n     *\n     * @return string\n     *\/\n    public function getAdjustmentCode()\n    {\n        return self::ADJUSTMENT_CODE;\n    }\n\n    \/**\n     * Define if adjustment is included in base price\n     *\n     * @return bool\n     *\/\n    public function isIncludedInBasePrice()\n    {\n        return true;\n    }\n\n    \/**\n     * Define if adjustment is included in display price\n     *\n     * @return bool\n     *\/\n    public function isIncludedInDisplayPrice()\n    {\n        return true;\n    }\n\n    \/**\n     * Extract adjustment amount from the given amount value\n     *\n     * @param float $amount\n     * @param SaleableInterface $saleableItem\n     * @param null|array $context\n     * @return float\n     *\/\n    public function extractAdjustment($amount, SaleableInterface $saleableItem, $context = &#091;])\n    {\n        return $amount - self::ADJUSTMENT_PRICE;\n    }\n\n    \/**\n     * Apply adjustment amount and return result value\n     *\n     * @param float $amount\n     * @param SaleableInterface $saleableItem\n     * @param null|array $context\n     * @return float\n     *\/\n    public function applyAdjustment($amount, SaleableInterface $saleableItem, $context = &#091;])\n    {\n        return $amount + self::ADJUSTMENT_PRICE;\n    }\n\n    \/**\n     * Check if adjustment should be excluded from calculations along with the given adjustment\n     *\n     * @param string $adjustmentCode\n     * @return bool\n     *\/\n    public function isExcludedWith($adjustmentCode)\n    {\n        return $this-&gt;getAdjustmentCode() === $adjustmentCode;\n    }\n\n    \/**\n     * Return sort order position\n     *\n     * @return int\n     *\/\n    public function getSortOrder()\n    {\n        return 21;\n    }\n}<\/pre>\n\n\n\n<p>From the above code one can adjust the price for all the saleable item in the inventory.<\/p>\n\n\n\n<p> <strong>ADJUSTMENT_CODE<\/strong> is unique for the adjustment Collection class.<\/p>\n\n\n\n<p>Collection Class : Magento\\Framework\\Pricing\\Adjustment\\Collection collection.<\/p>\n\n\n\n<p>The price of the saleable items in the inventory increase to amount ADJUSTMENT_PRICE defined as constant in Adjustment.php.<\/p>\n\n\n\n<p>Functions <strong>extractAdjustment<\/strong> and <strong>applyAdjustment<\/strong> in Adjustment.php contains the adjustment logic.<\/p>\n\n\n\n<p class=\"has-text-align-left\">Price adjustments affect only the price of the saleable items in product and category pages.<\/p>\n\n\n\n<p class=\"has-text-align-left\"> For adjusting the price of specific ID or specific type, one can get the info of saleable item from SaleableInterface $saleableItem. Price adjustments will not affect price of the items in the cart.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One can adjust the price of saleable entity at product and category page. For adjustments, create file etc\/di.xml in your module: Now create the Adjustment.php file : VENDOR\\MODULE\\Pricing\\Adjustment.php From the above code one can adjust the price for all the saleable item in the inventory. ADJUSTMENT_CODE is unique for the adjustment Collection class. Collection Class <a href=\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":277,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[],"class_list":["post-300398","post","type-post","status-publish","format-standard","hentry","category-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Adjust Price At Product And Category Page. - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Adjust price of product on all pages. Product price adjustment on all product and category pages. Adjust product price.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adjust Price At Product And Category Page. - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Adjust price of product on all pages. Product price adjustment on all product and category pages. Adjust product price.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-08T14:40:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-08T14:42:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Akash Rajput\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Akash Rajput\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\"},\"author\":{\"name\":\"Akash Rajput\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/9831fa86f42528fdcf494b59ff6cf6e2\"},\"headline\":\"Adjust Price At Product And Category Page.\",\"datePublished\":\"2021-08-08T14:40:47+00:00\",\"dateModified\":\"2021-08-08T14:42:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\"},\"wordCount\":154,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\",\"url\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\",\"name\":\"Adjust Price At Product And Category Page. - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2021-08-08T14:40:47+00:00\",\"dateModified\":\"2021-08-08T14:42:25+00:00\",\"description\":\"Adjust price of product on all pages. Product price adjustment on all product and category pages. Adjust product price.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adjust Price At Product And Category Page.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/9831fa86f42528fdcf494b59ff6cf6e2\",\"name\":\"Akash Rajput\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c7618982141d5bb19bbb0abea082fba6c06a2041a254b738d9132ec7f9c1bc20?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c7618982141d5bb19bbb0abea082fba6c06a2041a254b738d9132ec7f9c1bc20?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Akash Rajput\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/akash-rajput648\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adjust Price At Product And Category Page. - Webkul Blog","description":"Adjust price of product on all pages. Product price adjustment on all product and category pages. Adjust product price.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/","og_locale":"en_US","og_type":"article","og_title":"Adjust Price At Product And Category Page. - Webkul Blog","og_description":"Adjust price of product on all pages. Product price adjustment on all product and category pages. Adjust product price.","og_url":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-08-08T14:40:47+00:00","article_modified_time":"2021-08-08T14:42:25+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Akash Rajput","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Akash Rajput","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/"},"author":{"name":"Akash Rajput","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/9831fa86f42528fdcf494b59ff6cf6e2"},"headline":"Adjust Price At Product And Category Page.","datePublished":"2021-08-08T14:40:47+00:00","dateModified":"2021-08-08T14:42:25+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/"},"wordCount":154,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/","url":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/","name":"Adjust Price At Product And Category Page. - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2021-08-08T14:40:47+00:00","dateModified":"2021-08-08T14:42:25+00:00","description":"Adjust price of product on all pages. Product price adjustment on all product and category pages. Adjust product price.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/adjust-price-at-product-and-category-page\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Adjust Price At Product And Category Page."}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/9831fa86f42528fdcf494b59ff6cf6e2","name":"Akash Rajput","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c7618982141d5bb19bbb0abea082fba6c06a2041a254b738d9132ec7f9c1bc20?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c7618982141d5bb19bbb0abea082fba6c06a2041a254b738d9132ec7f9c1bc20?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Akash Rajput"},"url":"https:\/\/webkul.com\/blog\/author\/akash-rajput648\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/300398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/277"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=300398"}],"version-history":[{"count":16,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/300398\/revisions"}],"predecessor-version":[{"id":300414,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/300398\/revisions\/300414"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=300398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=300398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=300398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}